1
0

libs3.h 111 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562
  1. /** **************************************************************************
  2. * @file libs3.h
  3. * @details
  4. * Copyright 2008 Bryan Ischo <[email protected]>
  5. *
  6. * This file is part of libs3.
  7. *
  8. * libs3 is free software: you can redistribute it and/or modify it under the
  9. * terms of the GNU Lesser General Public License as published by the Free
  10. * Software Foundation, version 3 of the License.
  11. *
  12. * In addition, as a special exception, the copyright holders give
  13. * permission to link the code of this library and its programs with the
  14. * OpenSSL library, and distribute linked combinations including the two.
  15. *
  16. * libs3 is distributed in the hope that it will be useful, but WITHOUT ANY
  17. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  18. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  19. * details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public License
  22. * version 3 along with libs3, in a file named COPYING. If not, see
  23. * <https://www.gnu.org/licenses/>.
  24. *
  25. ************************************************************************** **/
  26. #ifndef LIBS3_H
  27. #define LIBS3_H
  28. #include <stdint.h>
  29. #ifndef WINSCP
  30. #include <sys/select.h>
  31. #endif
  32. #ifdef WINSCP
  33. #define LIBS3_VER_MAJOR "4"
  34. #define LIBS3_VER_MINOR "1"
  35. #endif
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. /** **************************************************************************
  40. * @mainpage
  41. * Overview
  42. * --------
  43. *
  44. * This library provides an API for using Amazon's S3 service (see
  45. * https://s3.amazonaws.com/). Its design goals are:
  46. *
  47. * - To provide a simple and straightforward API for accessing all of S3's
  48. * functionality
  49. * - To not require the developer using libs3 to need to know anything about:
  50. * - HTTP
  51. * - XML
  52. * - SSL
  53. *
  54. * In other words, this API is meant to stand on its own, without requiring
  55. * any implicit knowledge of how S3 services are accessed using HTTP
  56. * protocols.
  57. *
  58. * - To be usable from multithreaded code
  59. * - To be usable by code which wants to process multiple S3 requests
  60. * simultaneously from a single thread
  61. * - To be usable in the simple, straightforward way using sequentialized
  62. * blocking requests
  63. *
  64. * The general usage pattern of libs3 is:
  65. *
  66. * - Initialize libs3 once per program by calling S3_initialize() at program
  67. * start up time
  68. * - Make any number of requests to S3 for getting, putting, or listing
  69. * S3 buckets or objects, or modifying the ACLs associated with buckets
  70. * or objects, using one of three general approaches:
  71. * 1. Simple blocking requests, one at a time
  72. * 2. Multiple threads each making simple blocking requests
  73. * 3. From a single thread, managing multiple S3 requests simultaneously
  74. * using file descriptors and a select()/poll() loop
  75. * - Shut down libs3 at program exit time by calling S3_deinitialize()
  76. *
  77. * All functions which send requests to S3 return their results via a set of
  78. * callback functions which must be supplied to libs3 at the time that the
  79. * request is initiated. libs3 will call these functions back in the thread
  80. * calling the libs3 function if blocking requests are made (i.e., if the
  81. * S3RequestContext for the function invocation is passed in as NULL).
  82. * If an S3RequestContext is used to drive multiple S3 requests
  83. * simultaneously, then the callbacks will be made from the thread which
  84. * calls S3_runall_request_context() or S3_runonce_request_context(), or
  85. * possibly from the thread which calls S3_destroy_request_context(), if
  86. * S3 requests are in progress at the time that this function is called.
  87. *
  88. * NOTE: Response headers from Amazon S3 are limited to 4K (2K of metas is all
  89. * that Amazon supports, and libs3 allows Amazon an additional 2K of headers).
  90. *
  91. * NOTE: Because HTTP and the S3 REST protocol are highly under-specified,
  92. * libs3 must make some assumptions about the maximum length of certain HTTP
  93. * elements (such as headers) that it will accept. While efforts have been
  94. * made to enforce maximums which are beyond that expected to be needed by any
  95. * user of S3, it is always possible that these maximums may be too low in
  96. * some rare circumstances. Bug reports should this unlikely situation occur
  97. * would be most appreciated.
  98. *
  99. * Threading Rules
  100. * ---------------
  101. *
  102. * 1. All arguments passed to any function must not be modified directly until
  103. * the function returns.
  104. * 2. All S3RequestContext and S3Request arguments passed to all functions may
  105. * not be passed to any other libs3 function by any other thread until the
  106. * function returns.
  107. * 3. All functions may be called simultaneously by multiple threads as long
  108. * as (1) and (2) are observed, EXCEPT for S3_initialize(), which must be
  109. * called from one thread at a time only.
  110. * 4. All callbacks will be made in the thread of the caller of the function
  111. * which invoked them, so the caller of all libs3 functions should not hold
  112. * locks that it would try to re-acquire in a callback, as this may
  113. * deadlock.
  114. ************************************************************************** **/
  115. /** **************************************************************************
  116. * Constants
  117. ************************************************************************** **/
  118. /**
  119. * S3_MAX_HOSTNAME_SIZE is the maximum size we allow for a host name
  120. **/
  121. #define S3_MAX_HOSTNAME_SIZE 255
  122. /**
  123. * This is the default hostname that is being used for the S3 requests
  124. **/
  125. #define S3_DEFAULT_HOSTNAME "s3.amazonaws.com"
  126. /**
  127. * S3_MAX_BUCKET_NAME_SIZE is the maximum size of a bucket name.
  128. **/
  129. #define S3_MAX_BUCKET_NAME_SIZE 255
  130. /**
  131. * S3_MAX_KEY_SIZE is the maximum size of keys that Amazon S3 supports.
  132. **/
  133. #define S3_MAX_KEY_SIZE 1024
  134. /**
  135. * S3_MAX_METADATA_SIZE is the maximum number of bytes allowed for
  136. * x-amz-meta header names and values in any request passed to Amazon S3
  137. **/
  138. #define S3_MAX_METADATA_SIZE 2048
  139. /**
  140. * S3_METADATA_HEADER_NAME_PREFIX is the prefix of an S3 "meta header"
  141. **/
  142. #define S3_METADATA_HEADER_NAME_PREFIX "x-amz-meta-"
  143. /**
  144. * S3_MAX_METADATA_COUNT is the maximum number of x-amz-meta- headers that
  145. * could be included in a request to S3. The smallest meta header is
  146. * "x-amz-meta-n: v". Since S3 doesn't count the ": " against the total, the
  147. * smallest amount of data to count for a header would be the length of
  148. * "x-amz-meta-nv".
  149. **/
  150. #define S3_MAX_METADATA_COUNT \
  151. (S3_MAX_METADATA_SIZE / (sizeof(S3_METADATA_HEADER_NAME_PREFIX "nv") - 1))
  152. /**
  153. * S3_MAX_ACL_GRANT_COUNT is the maximum number of ACL grants that may be
  154. * set on a bucket or object at one time. It is also the maximum number of
  155. * ACL grants that the XML ACL parsing routine will parse.
  156. **/
  157. #define S3_MAX_ACL_GRANT_COUNT 100
  158. /**
  159. * This is the maximum number of characters (including terminating \0) that
  160. * libs3 supports in an ACL grantee email address.
  161. **/
  162. #define S3_MAX_GRANTEE_EMAIL_ADDRESS_SIZE 128
  163. /**
  164. * This is the maximum number of characters (including terminating \0) that
  165. * libs3 supports in an ACL grantee user id.
  166. **/
  167. #define S3_MAX_GRANTEE_USER_ID_SIZE 128
  168. /**
  169. * This is the maximum number of characters (including terminating \0) that
  170. * libs3 supports in an ACL grantee user display name.
  171. **/
  172. #define S3_MAX_GRANTEE_DISPLAY_NAME_SIZE 128
  173. /**
  174. * This is the maximum number of characters that will be stored in the
  175. * return buffer for the utility function which computes an HTTP authenticated
  176. * query string
  177. **/
  178. #define S3_MAX_AUTHENTICATED_QUERY_STRING_SIZE \
  179. (sizeof("https:///") + S3_MAX_HOSTNAME_SIZE + (S3_MAX_KEY_SIZE * 3) + \
  180. sizeof("?AWSAccessKeyId=") + 32 + sizeof("&Expires=") + 32 + \
  181. sizeof("&Signature=") + 28 + 1)
  182. /**
  183. * This constant is used by the S3_initialize() function, to specify that
  184. * the winsock library should be initialized by libs3; only relevent on
  185. * Microsoft Windows platforms.
  186. **/
  187. #define S3_INIT_WINSOCK 1
  188. /**
  189. * This constant is used by the S3_initialize() function, to enable peer SSL
  190. * certificate by default for all requests. If this is not set in the
  191. * flags passed to S3_initialize(), then the SSL certificate of the peer
  192. * will NOT be verified by default (but can still be enabled on a per request
  193. * basis by calling S3_set_request_context_verify_peer).
  194. */
  195. #define S3_INIT_VERIFY_PEER 2
  196. /**
  197. * This convenience constant is used by the S3_initialize() function to
  198. * indicate that all libraries required by libs3 should be initialized.
  199. **/
  200. #define S3_INIT_ALL (S3_INIT_WINSOCK)
  201. /**
  202. * The default region identifier used to scope the signing key
  203. */
  204. #define S3_DEFAULT_REGION "us-east-1"
  205. /** **************************************************************************
  206. * Enumerations
  207. ************************************************************************** **/
  208. /**
  209. * S3Status is a status code as returned by a libs3 function. The meaning of
  210. * each status code is defined in the comments for each function which returns
  211. * that status.
  212. **/
  213. typedef enum
  214. {
  215. S3StatusOK ,
  216. /**
  217. * Errors that prevent the S3 request from being issued or response from
  218. * being read
  219. **/
  220. S3StatusInternalError ,
  221. S3StatusOutOfMemory ,
  222. S3StatusInterrupted ,
  223. S3StatusInvalidBucketNameTooLong ,
  224. S3StatusInvalidBucketNameFirstCharacter ,
  225. S3StatusInvalidBucketNameCharacter ,
  226. S3StatusInvalidBucketNameCharacterSequence ,
  227. S3StatusInvalidBucketNameTooShort ,
  228. S3StatusInvalidBucketNameDotQuadNotation ,
  229. S3StatusQueryParamsTooLong ,
  230. S3StatusFailedToInitializeRequest ,
  231. S3StatusMetaDataHeadersTooLong ,
  232. S3StatusBadMetaData ,
  233. S3StatusBadContentType ,
  234. S3StatusContentTypeTooLong ,
  235. S3StatusBadMD5 ,
  236. S3StatusMD5TooLong ,
  237. S3StatusBadCacheControl ,
  238. S3StatusCacheControlTooLong ,
  239. S3StatusBadContentDispositionFilename ,
  240. S3StatusContentDispositionFilenameTooLong ,
  241. S3StatusBadContentEncoding ,
  242. S3StatusContentEncodingTooLong ,
  243. S3StatusBadIfMatchETag ,
  244. S3StatusIfMatchETagTooLong ,
  245. S3StatusBadIfNotMatchETag ,
  246. S3StatusIfNotMatchETagTooLong ,
  247. S3StatusHeadersTooLong ,
  248. S3StatusKeyTooLong ,
  249. S3StatusUriTooLong ,
  250. S3StatusXmlParseFailure ,
  251. S3StatusEmailAddressTooLong ,
  252. S3StatusUserIdTooLong ,
  253. S3StatusUserDisplayNameTooLong ,
  254. S3StatusGroupUriTooLong ,
  255. S3StatusPermissionTooLong ,
  256. S3StatusTargetBucketTooLong ,
  257. S3StatusTargetPrefixTooLong ,
  258. S3StatusTooManyGrants ,
  259. S3StatusBadGrantee ,
  260. S3StatusBadPermission ,
  261. S3StatusXmlDocumentTooLarge ,
  262. S3StatusNameLookupError ,
  263. S3StatusFailedToConnect ,
  264. S3StatusServerFailedVerification ,
  265. S3StatusConnectionFailed ,
  266. S3StatusAbortedByCallback ,
  267. S3StatusNotSupported ,
  268. /**
  269. * Errors from the S3 service
  270. **/
  271. S3StatusErrorAccessDenied ,
  272. S3StatusErrorAccountProblem ,
  273. S3StatusErrorAmbiguousGrantByEmailAddress ,
  274. S3StatusErrorBadDigest ,
  275. S3StatusErrorBucketAlreadyExists ,
  276. S3StatusErrorBucketAlreadyOwnedByYou ,
  277. S3StatusErrorBucketNotEmpty ,
  278. S3StatusErrorCredentialsNotSupported ,
  279. S3StatusErrorCrossLocationLoggingProhibited ,
  280. S3StatusErrorEntityTooSmall ,
  281. S3StatusErrorEntityTooLarge ,
  282. S3StatusErrorExpiredToken ,
  283. S3StatusErrorIllegalVersioningConfigurationException ,
  284. S3StatusErrorIncompleteBody ,
  285. S3StatusErrorIncorrectNumberOfFilesInPostRequest ,
  286. S3StatusErrorInlineDataTooLarge ,
  287. S3StatusErrorInternalError ,
  288. S3StatusErrorInvalidAccessKeyId ,
  289. S3StatusErrorInvalidAddressingHeader ,
  290. S3StatusErrorInvalidArgument ,
  291. S3StatusErrorInvalidBucketName ,
  292. S3StatusErrorInvalidBucketState ,
  293. S3StatusErrorInvalidDigest ,
  294. S3StatusErrorInvalidEncryptionAlgorithmError ,
  295. S3StatusErrorInvalidLocationConstraint ,
  296. S3StatusErrorInvalidObjectState ,
  297. S3StatusErrorInvalidPart ,
  298. S3StatusErrorInvalidPartOrder ,
  299. S3StatusErrorInvalidPayer ,
  300. S3StatusErrorInvalidPolicyDocument ,
  301. S3StatusErrorInvalidRange ,
  302. S3StatusErrorInvalidRequest ,
  303. S3StatusErrorInvalidSecurity ,
  304. S3StatusErrorInvalidSOAPRequest ,
  305. S3StatusErrorInvalidStorageClass ,
  306. S3StatusErrorInvalidTargetBucketForLogging ,
  307. S3StatusErrorInvalidToken ,
  308. S3StatusErrorInvalidURI ,
  309. S3StatusErrorKeyTooLong ,
  310. S3StatusErrorMalformedACLError ,
  311. S3StatusErrorMalformedPOSTRequest ,
  312. S3StatusErrorMalformedXML ,
  313. S3StatusErrorMaxMessageLengthExceeded ,
  314. S3StatusErrorMaxPostPreDataLengthExceededError ,
  315. S3StatusErrorMetadataTooLarge ,
  316. S3StatusErrorMethodNotAllowed ,
  317. S3StatusErrorMissingAttachment ,
  318. S3StatusErrorMissingContentLength ,
  319. S3StatusErrorMissingRequestBodyError ,
  320. S3StatusErrorMissingSecurityElement ,
  321. S3StatusErrorMissingSecurityHeader ,
  322. S3StatusErrorNoLoggingStatusForKey ,
  323. S3StatusErrorNoSuchBucket ,
  324. S3StatusErrorNoSuchKey ,
  325. S3StatusErrorNoSuchLifecycleConfiguration ,
  326. S3StatusErrorNoSuchUpload ,
  327. S3StatusErrorNoSuchVersion ,
  328. S3StatusErrorNotImplemented ,
  329. S3StatusErrorNotSignedUp ,
  330. S3StatusErrorNoSuchBucketPolicy ,
  331. S3StatusErrorOperationAborted ,
  332. S3StatusErrorPermanentRedirect ,
  333. S3StatusErrorPreconditionFailed ,
  334. S3StatusErrorRedirect ,
  335. S3StatusErrorRestoreAlreadyInProgress ,
  336. S3StatusErrorRequestIsNotMultiPartContent ,
  337. S3StatusErrorRequestTimeout ,
  338. S3StatusErrorRequestTimeTooSkewed ,
  339. S3StatusErrorRequestTorrentOfBucketError ,
  340. S3StatusErrorSignatureDoesNotMatch ,
  341. S3StatusErrorServiceUnavailable ,
  342. S3StatusErrorSlowDown ,
  343. S3StatusErrorTemporaryRedirect ,
  344. S3StatusErrorTokenRefreshRequired ,
  345. S3StatusErrorTooManyBuckets ,
  346. S3StatusErrorUnexpectedContent ,
  347. S3StatusErrorUnresolvableGrantByEmailAddress ,
  348. S3StatusErrorUserKeyMustBeSpecified ,
  349. S3StatusErrorQuotaExceeded ,
  350. S3StatusErrorAuthorizationHeaderMalformed , // WINSCP
  351. S3StatusErrorUnknown ,
  352. /**
  353. * The following are HTTP errors returned by S3 without enough detail to
  354. * distinguish any of the above S3StatusError conditions
  355. **/
  356. S3StatusHttpErrorMovedTemporarily ,
  357. S3StatusHttpErrorBadRequest ,
  358. S3StatusHttpErrorForbidden ,
  359. S3StatusHttpErrorNotFound ,
  360. S3StatusHttpErrorConflict ,
  361. S3StatusHttpErrorUnknown
  362. } S3Status;
  363. /**
  364. * S3Protocol represents a protocol that may be used for communicating a
  365. * request to the Amazon S3 service.
  366. *
  367. * In general, HTTPS is greatly preferred (and should be the default of any
  368. * application using libs3) because it protects any data being sent to or
  369. * from S3 using strong encryption. However, HTTPS is much more CPU intensive
  370. * than HTTP, and if the caller is absolutely certain that it is OK for the
  371. * data to be viewable by anyone in transit, then HTTP can be used.
  372. **/
  373. typedef enum
  374. {
  375. S3ProtocolHTTPS = 0,
  376. S3ProtocolHTTP = 1
  377. } S3Protocol;
  378. /**
  379. * S3UriStyle defines the form that an Amazon S3 URI identifying a bucket or
  380. * object can take. They are of these forms:
  381. *
  382. * Virtual Host: ${protocol}://${bucket}.s3.amazonaws.com/[${key}]
  383. * Path: ${protocol}://s3.amazonaws.com/${bucket}/[${key}]
  384. *
  385. * It is generally better to use the Virual Host URI form, because it ensures
  386. * that the bucket name used is compatible with normal HTTP GETs and POSTs of
  387. * data to/from the bucket. However, if DNS lookups for the bucket are too
  388. * slow or unreliable for some reason, Path URI form may be used.
  389. **/
  390. typedef enum
  391. {
  392. S3UriStyleVirtualHost = 0,
  393. S3UriStylePath = 1
  394. } S3UriStyle;
  395. /**
  396. * S3GranteeType defines the type of Grantee used in an S3 ACL Grant.
  397. * Amazon Customer By Email - identifies the Grantee using their Amazon S3
  398. * account email address
  399. * Canonical User - identifies the Grantee by S3 User ID and Display Name,
  400. * which can only be obtained by making requests to S3, for example, by
  401. * listing owned buckets
  402. * All AWS Users - identifies all authenticated AWS users
  403. * All Users - identifies all users
  404. * Log Delivery - identifies the Amazon group responsible for writing
  405. * server access logs into buckets
  406. **/
  407. typedef enum
  408. {
  409. S3GranteeTypeAmazonCustomerByEmail = 0,
  410. S3GranteeTypeCanonicalUser = 1,
  411. S3GranteeTypeAllAwsUsers = 2,
  412. S3GranteeTypeAllUsers = 3,
  413. S3GranteeTypeLogDelivery = 4
  414. } S3GranteeType;
  415. /**
  416. * This is an individual permission granted to a grantee in an S3 ACL Grant.
  417. * Read permission gives the Grantee the permission to list the bucket, or
  418. * read the object or its metadata
  419. * Write permission gives the Grantee the permission to create, overwrite, or
  420. * delete any object in the bucket, and is not supported for objects
  421. * ReadACP permission gives the Grantee the permission to read the ACP for
  422. * the bucket or object; the owner of the bucket or object always has
  423. * this permission implicitly
  424. * WriteACP permission gives the Grantee the permission to overwrite the ACP
  425. * for the bucket or object; the owner of the bucket or object always has
  426. * this permission implicitly
  427. * FullControl permission gives the Grantee all permissions specified by the
  428. * Read, Write, ReadACP, and WriteACP permissions
  429. **/
  430. typedef enum
  431. {
  432. S3PermissionRead = 0,
  433. S3PermissionWrite = 1,
  434. S3PermissionReadACP = 2,
  435. S3PermissionWriteACP = 3,
  436. S3PermissionFullControl = 4
  437. } S3Permission;
  438. /**
  439. * S3CannedAcl is an ACL that can be specified when an object is created or
  440. * updated. Each canned ACL has a predefined value when expanded to a full
  441. * set of S3 ACL Grants.
  442. * Private canned ACL gives the owner FULL_CONTROL and no other permissions
  443. * are issued
  444. * Public Read canned ACL gives the owner FULL_CONTROL and all users Read
  445. * permission
  446. * Public Read Write canned ACL gives the owner FULL_CONTROL and all users
  447. * Read and Write permission
  448. * AuthenticatedRead canned ACL gives the owner FULL_CONTROL and authenticated
  449. * S3 users Read permission
  450. **/
  451. typedef enum
  452. {
  453. S3CannedAclPrivate = 0, /* private */
  454. S3CannedAclPublicRead = 1, /* public-read */
  455. S3CannedAclPublicReadWrite = 2, /* public-read-write */
  456. S3CannedAclAuthenticatedRead = 3 /* authenticated-read */
  457. } S3CannedAcl;
  458. /** **************************************************************************
  459. * Data Types
  460. ************************************************************************** **/
  461. /**
  462. * An S3RequestContext manages multiple S3 requests simultaneously; see the
  463. * S3_XXX_request_context functions below for details
  464. **/
  465. typedef struct S3RequestContext S3RequestContext;
  466. /**
  467. * S3NameValue represents a single Name - Value pair, used to represent either
  468. * S3 metadata associated with a key, or S3 error details.
  469. **/
  470. typedef struct S3NameValue
  471. {
  472. /**
  473. * The name part of the Name - Value pair
  474. **/
  475. const char *name;
  476. /**
  477. * The value part of the Name - Value pair
  478. **/
  479. const char *value;
  480. } S3NameValue;
  481. /**
  482. * S3ResponseProperties is passed to the properties callback function which is
  483. * called when the complete response properties have been received. Some of
  484. * the fields of this structure are optional and may not be provided in the
  485. * response, and some will always be provided in the response.
  486. **/
  487. typedef struct S3ResponseProperties
  488. {
  489. /**
  490. * This optional field identifies the request ID and may be used when
  491. * reporting problems to Amazon.
  492. **/
  493. const char *requestId;
  494. /**
  495. * This optional field identifies the request ID and may be used when
  496. * reporting problems to Amazon.
  497. **/
  498. const char *requestId2;
  499. /**
  500. * This optional field is the content type of the data which is returned
  501. * by the request. If not provided, the default can be assumed to be
  502. * "binary/octet-stream".
  503. **/
  504. const char *contentType;
  505. /**
  506. * This optional field is the content length of the data which is returned
  507. * in the response. A negative value means that this value was not
  508. * provided in the response. A value of 0 means that there is no content
  509. * provided. A positive value gives the number of bytes in the content of
  510. * the response.
  511. **/
  512. uint64_t contentLength;
  513. /**
  514. * This optional field names the server which serviced the request.
  515. **/
  516. const char *server;
  517. /**
  518. * This optional field provides a string identifying the unique contents
  519. * of the resource identified by the request, such that the contents can
  520. * be assumed not to be changed if the same eTag is returned at a later
  521. * time decribing the same resource. This is an MD5 sum of the contents.
  522. **/
  523. const char *eTag;
  524. /**
  525. * This optional field provides the last modified time, relative to the
  526. * Unix epoch, of the contents. If this value is < 0, then the last
  527. * modified time was not provided in the response. If this value is >= 0,
  528. * then the last modified date of the contents are available as a number
  529. * of seconds since the UNIX epoch.
  530. *
  531. **/
  532. int64_t lastModified;
  533. /**
  534. * This is the number of user-provided meta data associated with the
  535. * resource.
  536. **/
  537. int metaDataCount;
  538. /**
  539. * These are the meta data associated with the resource. In each case,
  540. * the name will not include any S3-specific header prefixes
  541. * (i.e. x-amz-meta- will have been removed from the beginning), and
  542. * leading and trailing whitespace will have been stripped from the value.
  543. **/
  544. const S3NameValue *metaData;
  545. /**
  546. * This optional field provides an indication of whether or not
  547. * server-side encryption was used for the object. This field is only
  548. * meaningful if the request was an object put, copy, get, or head
  549. * request.
  550. * If this value is 0, then server-side encryption is not in effect for
  551. * the object (or the request was one for which server-side encryption is
  552. * not a meaningful value); if this value is non-zero, then server-side
  553. * encryption is in effect for the object.
  554. **/
  555. char usesServerSideEncryption;
  556. } S3ResponseProperties;
  557. /**
  558. * S3AclGrant identifies a single grant in the ACL for a bucket or object. An
  559. * ACL is composed of any number of grants, which specify a grantee and the
  560. * permissions given to that grantee. S3 does not normalize ACLs in any way,
  561. * so a redundant ACL specification will lead to a redundant ACL stored in S3.
  562. **/
  563. typedef struct S3AclGrant
  564. {
  565. /**
  566. * The granteeType gives the type of grantee specified by this grant.
  567. **/
  568. S3GranteeType granteeType;
  569. /**
  570. * The identifier of the grantee that is set is determined by the
  571. * granteeType:
  572. *
  573. * S3GranteeTypeAmazonCustomerByEmail - amazonCustomerByEmail.emailAddress
  574. * S3GranteeTypeCanonicalUser - canonicalUser.id, canonicalUser.displayName
  575. * S3GranteeTypeAllAwsUsers - none
  576. * S3GranteeTypeAllUsers - none
  577. **/
  578. union
  579. {
  580. /**
  581. * This structure is used iff the granteeType is
  582. * S3GranteeTypeAmazonCustomerByEmail.
  583. **/
  584. struct
  585. {
  586. /**
  587. * This is the email address of the Amazon Customer being granted
  588. * permissions by this S3AclGrant.
  589. **/
  590. char emailAddress[S3_MAX_GRANTEE_EMAIL_ADDRESS_SIZE];
  591. } amazonCustomerByEmail;
  592. /**
  593. * This structure is used iff the granteeType is
  594. * S3GranteeTypeCanonicalUser.
  595. **/
  596. struct
  597. {
  598. /**
  599. * This is the CanonicalUser ID of the grantee
  600. **/
  601. char id[S3_MAX_GRANTEE_USER_ID_SIZE];
  602. /**
  603. * This is the display name of the grantee
  604. **/
  605. char displayName[S3_MAX_GRANTEE_DISPLAY_NAME_SIZE];
  606. } canonicalUser;
  607. } grantee;
  608. /**
  609. * This is the S3Permission to be granted to the grantee
  610. **/
  611. S3Permission permission;
  612. } S3AclGrant;
  613. /**
  614. * A context for working with objects within a bucket. A bucket context holds
  615. * all information necessary for working with a bucket, and may be used
  616. * repeatedly over many consecutive (or simultaneous) calls into libs3 bucket
  617. * operation functions.
  618. **/
  619. typedef struct S3BucketContext
  620. {
  621. /**
  622. * The name of the host to connect to when making S3 requests. If set to
  623. * NULL, the default S3 hostname passed in to S3_initialize will be used.
  624. **/
  625. const char *hostName;
  626. /**
  627. * The name of the bucket to use in the bucket context
  628. **/
  629. const char *bucketName;
  630. /**
  631. * The protocol to use when accessing the bucket
  632. **/
  633. S3Protocol protocol;
  634. /**
  635. * The URI style to use for all URIs sent to Amazon S3 while working with
  636. * this bucket context
  637. **/
  638. S3UriStyle uriStyle;
  639. /**
  640. * The Amazon Access Key ID to use for access to the bucket
  641. **/
  642. const char *accessKeyId;
  643. /**
  644. * The Amazon Secret Access Key to use for access to the bucket
  645. **/
  646. const char *secretAccessKey;
  647. /**
  648. * The Amazon Security Token used to generate Temporary Security Credentials
  649. **/
  650. const char *securityToken;
  651. /**
  652. * The AWS region to which to scope the signing key used for authorization.
  653. * If NULL, the default region ("us-east-1") will be used.
  654. */
  655. const char *authRegion;
  656. } S3BucketContext;
  657. /**
  658. * This is a single entry supplied to the list bucket callback by a call to
  659. * S3_list_bucket. It identifies a single matching key from the list
  660. * operation.
  661. **/
  662. typedef struct S3ListBucketContent
  663. {
  664. /**
  665. * This is the next key in the list bucket results.
  666. **/
  667. const char *key;
  668. /**
  669. * This is the number of seconds since UNIX epoch of the last modified
  670. * date of the object identified by the key.
  671. **/
  672. int64_t lastModified;
  673. /**
  674. * This gives a tag which gives a signature of the contents of the object,
  675. * which is the MD5 of the contents of the object.
  676. **/
  677. const char *eTag;
  678. /**
  679. * This is the size of the object in bytes.
  680. **/
  681. uint64_t size;
  682. /**
  683. * This is the ID of the owner of the key; it is present only if access
  684. * permissions allow it to be viewed.
  685. **/
  686. const char *ownerId;
  687. /**
  688. * This is the display name of the owner of the key; it is present only if
  689. * access permissions allow it to be viewed.
  690. **/
  691. const char *ownerDisplayName;
  692. } S3ListBucketContent;
  693. /**
  694. * This is a single entry supplied to the list bucket callback by a call to
  695. * S3_list_bucket. It identifies a single matching key from the list
  696. * operation.
  697. **/
  698. typedef struct S3ListMultipartUpload
  699. {
  700. /**
  701. * This is the next key in the list bucket results.
  702. **/
  703. const char *key;
  704. const char *uploadId;
  705. const char *initiatorId;
  706. const char *initiatorDisplayName;
  707. /**
  708. * This is the ID of the owner of the key; it is present only if access
  709. * permissions allow it to be viewed.
  710. **/
  711. const char *ownerId;
  712. /**
  713. * This is the display name of the owner of the key; it is present only if
  714. * access permissions allow it to be viewed.
  715. **/
  716. const char *ownerDisplayName;
  717. const char *storageClass;
  718. /**
  719. * This is the number of seconds since UNIX epoch of the last modified
  720. * date of the object identified by the key.
  721. **/
  722. int64_t initiated;
  723. } S3ListMultipartUpload;
  724. typedef struct S3ListPart
  725. {
  726. const char *eTag;
  727. /**
  728. * This is the number of seconds since UNIX epoch of the last modified
  729. * date of the object identified by the key.
  730. **/
  731. int64_t lastModified;
  732. uint64_t partNumber;
  733. uint64_t size;
  734. } S3ListPart;
  735. /**
  736. * S3PutProperties is the set of properties that may optionally be set by the
  737. * user when putting objects to S3. Each field of this structure is optional
  738. * and may or may not be present.
  739. **/
  740. typedef struct S3PutProperties
  741. {
  742. /**
  743. * If present, this is the Content-Type that should be associated with the
  744. * object. If not provided, S3 defaults to "binary/octet-stream".
  745. **/
  746. const char *contentType;
  747. /**
  748. * If present, this provides the MD5 signature of the contents, and is
  749. * used to validate the contents. This is highly recommended by Amazon
  750. * but not required. Its format is as a base64-encoded MD5 sum.
  751. **/
  752. const char *md5;
  753. /**
  754. * If present, this gives a Cache-Control header string to be supplied to
  755. * HTTP clients which download this
  756. **/
  757. const char *cacheControl;
  758. /**
  759. * If present, this gives the filename to save the downloaded file to,
  760. * whenever the object is downloaded via a web browser. This is only
  761. * relevent for objects which are intended to be shared to users via web
  762. * browsers and which is additionally intended to be downloaded rather
  763. * than viewed.
  764. **/
  765. const char *contentDispositionFilename;
  766. /**
  767. * If present, this identifies the content encoding of the object. This
  768. * is only applicable to encoded (usually, compressed) content, and only
  769. * relevent if the object is intended to be downloaded via a browser.
  770. **/
  771. const char *contentEncoding;
  772. /**
  773. * If >= 0, this gives an expiration date for the content. This
  774. * information is typically only delivered to users who download the
  775. * content via a web browser.
  776. **/
  777. int64_t expires;
  778. /**
  779. * This identifies the "canned ACL" that should be used for this object.
  780. * The default (0) gives only the owner of the object access to it.
  781. **/
  782. S3CannedAcl cannedAcl;
  783. /**
  784. * This is the number of values in the metaData field.
  785. **/
  786. int metaDataCount;
  787. /**
  788. * These are the meta data to pass to S3. In each case, the name part of
  789. * the Name - Value pair should not include any special S3 HTTP header
  790. * prefix (i.e., should be of the form 'foo', NOT 'x-amz-meta-foo').
  791. **/
  792. const S3NameValue *metaData;
  793. /**
  794. * This a boolean value indicating whether or not the object should be
  795. * stored by Amazon S3 using server-side encryption, wherein the data is
  796. * encrypted by Amazon before being stored on permanent medium.
  797. * Server-side encryption does not affect the data as it is sent to or
  798. * received by Amazon, the encryption is applied by Amazon when objects
  799. * are put and then de-encryption is applied when the objects are read by
  800. * clients.
  801. * If this value is 0, then server-side encryption is not used; if this
  802. * value is non-zero, then server-side encryption is used. Note that the
  803. * encryption status of the object can be checked by ensuring that the put
  804. * response has the usesServerSideEncryption flag set.
  805. **/
  806. char useServerSideEncryption;
  807. } S3PutProperties;
  808. /**
  809. * S3GetConditions is used for the get_object operation, and specifies
  810. * conditions which the object must meet in order to be successfully returned.
  811. **/
  812. typedef struct S3GetConditions
  813. {
  814. /**
  815. * The request will be processed if the Last-Modification header of the
  816. * object is greater than or equal to this value, specified as a number of
  817. * seconds since Unix epoch. If this value is less than zero, it will not
  818. * be used in the conditional.
  819. **/
  820. int64_t ifModifiedSince;
  821. /**
  822. * The request will be processed if the Last-Modification header of the
  823. * object is less than this value, specified as a number of seconds since
  824. * Unix epoch. If this value is less than zero, it will not be used in
  825. * the conditional.
  826. **/
  827. int64_t ifNotModifiedSince;
  828. /**
  829. * If non-NULL, this gives an eTag header value which the object must
  830. * match in order to be returned. Note that altough the eTag is simply an
  831. * MD5, this must be presented in the S3 eTag form, which typically
  832. * includes double-quotes.
  833. **/
  834. const char *ifMatchETag;
  835. /**
  836. * If non-NULL, this gives an eTag header value which the object must not
  837. * match in order to be returned. Note that altough the eTag is simply an
  838. * MD5, this must be presented in the S3 eTag form, which typically
  839. * includes double-quotes.
  840. **/
  841. const char *ifNotMatchETag;
  842. } S3GetConditions;
  843. /**
  844. * S3ErrorDetails provides detailed information describing an S3 error. This
  845. * is only presented when the error is an S3-generated error (i.e. one of the
  846. * S3StatusErrorXXX values).
  847. **/
  848. typedef struct S3ErrorDetails
  849. {
  850. /**
  851. * This is the human-readable message that Amazon supplied describing the
  852. * error
  853. **/
  854. const char *message;
  855. /**
  856. * This identifies the resource for which the error occurred
  857. **/
  858. const char *resource;
  859. /**
  860. * This gives human-readable further details describing the specifics of
  861. * this error
  862. **/
  863. const char *furtherDetails;
  864. /**
  865. * This gives the number of S3NameValue pairs present in the extraDetails
  866. * array
  867. **/
  868. int extraDetailsCount;
  869. /**
  870. * S3 can provide extra details in a freeform Name - Value pair format.
  871. * Each error can have any number of these, and this array provides these
  872. * additional extra details.
  873. **/
  874. S3NameValue *extraDetails;
  875. } S3ErrorDetails;
  876. /** **************************************************************************
  877. * Callback Signatures
  878. ************************************************************************** **/
  879. /**
  880. * This callback is made whenever the response properties become available for
  881. * any request.
  882. *
  883. * @param properties are the properties that are available from the response
  884. * @param callbackData is the callback data as specified when the request
  885. * was issued.
  886. * @return S3StatusOK to continue processing the request, anything else to
  887. * immediately abort the request with a status which will be
  888. * passed to the S3ResponseCompleteCallback for this request.
  889. * Typically, this will return either S3StatusOK or
  890. * S3StatusAbortedByCallback.
  891. **/
  892. typedef S3Status (S3ResponsePropertiesCallback)
  893. (const S3ResponseProperties *properties, void *callbackData);
  894. /**
  895. * This callback is made when the response has been completely received, or an
  896. * error has occurred which has prematurely aborted the request, or one of the
  897. * other user-supplied callbacks returned a value intended to abort the
  898. * request. This callback is always made for every request, as the very last
  899. * callback made for that request.
  900. *
  901. * @param status gives the overall status of the response, indicating success
  902. * or failure; use S3_status_is_retryable() as a simple way to detect
  903. * whether or not the status indicates that the request failed but may
  904. * be retried.
  905. * @param errorDetails if non-NULL, gives details as returned by the S3
  906. * service, describing the error
  907. * @param callbackData is the callback data as specified when the request
  908. * was issued.
  909. **/
  910. typedef void (S3ResponseCompleteCallback)(S3Status status,
  911. const S3ErrorDetails *errorDetails,
  912. void *callbackData);
  913. /**
  914. * This callback is made for each bucket resulting from a list service
  915. * operation.
  916. *
  917. * @param ownerId is the ID of the owner of the bucket
  918. * @param ownerDisplayName is the owner display name of the owner of the bucket
  919. * @param bucketName is the name of the bucket
  920. * @param creationDateSeconds if < 0 indicates that no creation date was
  921. * supplied for the bucket; if >= 0 indicates the number of seconds
  922. * since UNIX Epoch of the creation date of the bucket
  923. * @param callbackData is the callback data as specified when the request
  924. * was issued.
  925. * @return S3StatusOK to continue processing the request, anything else to
  926. * immediately abort the request with a status which will be
  927. * passed to the S3ResponseCompleteCallback for this request.
  928. * Typically, this will return either S3StatusOK or
  929. * S3StatusAbortedByCallback.
  930. **/
  931. typedef S3Status (S3ListServiceCallback)(const char *ownerId,
  932. const char *ownerDisplayName,
  933. const char *bucketName,
  934. int64_t creationDateSeconds,
  935. void *callbackData);
  936. /**
  937. * This callback is made repeatedly as a list bucket operation progresses.
  938. * The contents reported via this callback are only reported once per list
  939. * bucket operation, but multiple calls to this callback may be necessary to
  940. * report all items resulting from the list bucket operation.
  941. *
  942. * @param isTruncated is true if the list bucket request was truncated by the
  943. * S3 service, in which case the remainder of the list may be obtained
  944. * by querying again using the Marker parameter to start the query
  945. * after this set of results
  946. * @param nextMarker if present, gives the largest (alphabetically) key
  947. * returned in the response, which, if isTruncated is true, may be used
  948. * as the marker in a subsequent list buckets operation to continue
  949. * listing
  950. * @param contentsCount is the number of ListBucketContent structures in the
  951. * contents parameter
  952. * @param contents is an array of ListBucketContent structures, each one
  953. * describing an object in the bucket
  954. * @param commonPrefixesCount is the number of common prefixes strings in the
  955. * commonPrefixes parameter
  956. * @param commonPrefixes is an array of strings, each specifing one of the
  957. * common prefixes as returned by S3
  958. * @param callbackData is the callback data as specified when the request
  959. * was issued.
  960. * @return S3StatusOK to continue processing the request, anything else to
  961. * immediately abort the request with a status which will be
  962. * passed to the S3ResponseCompleteCallback for this request.
  963. * Typically, this will return either S3StatusOK or
  964. * S3StatusAbortedByCallback.
  965. **/
  966. typedef S3Status (S3ListBucketCallback)(int isTruncated,
  967. const char *nextMarker,
  968. int contentsCount,
  969. const S3ListBucketContent *contents,
  970. int commonPrefixesCount,
  971. const char **commonPrefixes,
  972. void *callbackData);
  973. /**
  974. * This callback is made during a put object operation, to obtain the next
  975. * chunk of data to put to the S3 service as the contents of the object. This
  976. * callback is made repeatedly, each time acquiring the next chunk of data to
  977. * write to the service, until a negative or 0 value is returned.
  978. *
  979. * @param bufferSize gives the maximum number of bytes that may be written
  980. * into the buffer parameter by this callback
  981. * @param buffer gives the buffer to fill with at most bufferSize bytes of
  982. * data as the next chunk of data to send to S3 as the contents of this
  983. * object
  984. * @param callbackData is the callback data as specified when the request
  985. * was issued.
  986. * @return < 0 to abort the request with the S3StatusAbortedByCallback, which
  987. * will be pased to the response complete callback for this request, or
  988. * 0 to indicate the end of data, or > 0 to identify the number of
  989. * bytes that were written into the buffer by this callback
  990. **/
  991. typedef int (S3PutObjectDataCallback)(int bufferSize, char *buffer,
  992. void *callbackData);
  993. /**
  994. * This callback is made during a get object operation, to provide the next
  995. * chunk of data available from the S3 service constituting the contents of
  996. * the object being fetched. This callback is made repeatedly, each time
  997. * providing the next chunk of data read, until the complete object contents
  998. * have been passed through the callback in this way, or the callback
  999. * returns an error status.
  1000. *
  1001. * @param bufferSize gives the number of bytes in buffer
  1002. * @param buffer is the data being passed into the callback
  1003. * @param callbackData is the callback data as specified when the request
  1004. * was issued.
  1005. * @return S3StatusOK to continue processing the request, anything else to
  1006. * immediately abort the request with a status which will be
  1007. * passed to the S3ResponseCompleteCallback for this request.
  1008. * Typically, this will return either S3StatusOK or
  1009. * S3StatusAbortedByCallback.
  1010. **/
  1011. typedef S3Status (S3GetObjectDataCallback)(int bufferSize, const char *buffer,
  1012. void *callbackData);
  1013. /**
  1014. * This callback is made after initiation of a multipart upload operation. It
  1015. * indicates that the multi part upload has been created and provides the
  1016. * id that can be used to associate multi upload parts with the multi upload
  1017. * operation
  1018. *
  1019. * @param upload_id is the unique identifier if this multi part upload
  1020. * operation, to be used in calls to S3_upload_part and
  1021. * S3_complete_multipart_upload
  1022. * @param callbackData is the callback data as specified when the request
  1023. * was issued.
  1024. * @return S3StatusOK to continue processing the request, anything else to
  1025. * immediately abort the request with a status which will be
  1026. * passed to the S3ResponseCompleteCallback for this request.
  1027. * Typically, this will return either S3StatusOK or
  1028. * S3StatusAbortedByCallback.
  1029. **/
  1030. typedef S3Status (S3MultipartInitialResponseCallback)(const char *upload_id,
  1031. void *callbackData);
  1032. /**
  1033. * This callback is made after completion of a part of a multipart upload
  1034. * operation. It is a status callback indicating that the multipart upload is
  1035. * in progress and that some sub-set of the parts have completed upload. The
  1036. * multipart upload is not considered fully complete in total until the commit
  1037. * response callback is made.
  1038. *
  1039. * @param isTruncated is ??? someone document this please
  1040. * @param nextKeyMarker is ??? someone document this please
  1041. * @param nextUploadIdMarker is ??? someone document this please
  1042. * @param uploadsCount is the number of elements in the [uploads] array
  1043. * @param uploads is an array of ??? someone document this please
  1044. * @param commonPrefixesCount is the number of elements in the
  1045. * [commonPrefixes] array
  1046. * @param commonPrefixes is ??? someone document this please
  1047. * @param callbackData is the callback data as specified when the request
  1048. * was issued.
  1049. * @return S3StatusOK to continue processing the request, anything else to
  1050. * immediately abort the request with a status which will be
  1051. * passed to the S3ResponseCompleteCallback for this request.
  1052. * Typically, this will return either S3StatusOK or
  1053. * S3StatusAbortedByCallback.
  1054. **/
  1055. typedef S3Status (S3ListMultipartUploadsResponseCallback)
  1056. (int isTruncated, const char *nextKeyMarker,
  1057. const char *nextUploadIdMarker, int uploadsCount,
  1058. const S3ListMultipartUpload *uploads, int commonPrefixesCount,
  1059. const char **commonPrefixes, void *callbackData);
  1060. /**
  1061. * This callback is made with the result of a succesful "list parts" request
  1062. * to list the parts of a multi part upload (in progress???).
  1063. *
  1064. * @param isTruncated is ??? someone document this please
  1065. * @param nextPartNumberMarker is ??? someone document this please
  1066. * @param intiatorId is ??? someone document this please
  1067. * @param initiatorDisplayName is ??? someone document this please
  1068. * @param ownerId is ??? someone document this please
  1069. * @param ownerDisplayName is ??? someone document this please
  1070. * @param storageClass is ??? someone document this please
  1071. * @param partsCount is ??? someone document this please
  1072. * @param lastPartNumber is ??? someone document this please
  1073. * @param parts is ??? someone document this please
  1074. * @param callbackData is the callback data as specified when the request
  1075. * was issued.
  1076. * @return S3StatusOK to continue processing the request, anything else to
  1077. * immediately abort the request with a status which will be
  1078. * passed to the S3ResponseCompleteCallback for this request.
  1079. * Typically, this will return either S3StatusOK or
  1080. * S3StatusAbortedByCallback.
  1081. **/
  1082. typedef S3Status (S3ListPartsResponseCallback)
  1083. (int isTruncated, const char *nextPartNumberMarker,
  1084. const char *initiatorId, const char *initiatorDisplayName,
  1085. const char *ownerId, const char *ownerDisplayName,
  1086. const char *storageClass, int partsCount, int lastPartNumber,
  1087. const S3ListPart *parts, void *callbackData);
  1088. /**
  1089. * This callback is made after commit of a multipart upload operation. It
  1090. * indicates that the data uploaded via the multipart upload operation has
  1091. * been committed.
  1092. *
  1093. * @param location is ??? someone please document this
  1094. * @param etag is the S3 etag of the complete object after the multipart
  1095. * upload
  1096. * @param callbackData is the callback data as specified when the request
  1097. * was issued.
  1098. * @return S3StatusOK to continue processing the request, anything else to
  1099. * immediately abort the request with a status which will be
  1100. * passed to the S3ResponseCompleteCallback for this request.
  1101. * Typically, this will return either S3StatusOK or
  1102. * S3StatusAbortedByCallback.
  1103. **/
  1104. typedef S3Status (S3MultipartCommitResponseCallback)(const char *location,
  1105. const char *etag,
  1106. void *callbackData);
  1107. /** **************************************************************************
  1108. * Callback Structures
  1109. ************************************************************************** **/
  1110. /**
  1111. * An S3ResponseHandler defines the callbacks which are made for any
  1112. * request.
  1113. **/
  1114. typedef struct S3ResponseHandler
  1115. {
  1116. /**
  1117. * The propertiesCallback is made when the response properties have
  1118. * successfully been returned from S3. This function may not be called
  1119. * if the response properties were not successfully returned from S3.
  1120. **/
  1121. S3ResponsePropertiesCallback *propertiesCallback;
  1122. /**
  1123. * The completeCallback is always called for every request made to S3,
  1124. * regardless of the outcome of the request. It provides the status of
  1125. * the request upon its completion, as well as extra error details in the
  1126. * event of an S3 error.
  1127. **/
  1128. S3ResponseCompleteCallback *completeCallback;
  1129. } S3ResponseHandler;
  1130. /**
  1131. * An S3ListServiceHandler defines the callbacks which are made for
  1132. * list_service requests.
  1133. **/
  1134. typedef struct S3ListServiceHandler
  1135. {
  1136. /**
  1137. * responseHandler provides the properties and complete callback
  1138. **/
  1139. S3ResponseHandler responseHandler;
  1140. /**
  1141. * The listServiceCallback is called as items are reported back from S3 as
  1142. * responses to the request
  1143. **/
  1144. S3ListServiceCallback *listServiceCallback;
  1145. } S3ListServiceHandler;
  1146. /**
  1147. * An S3ListBucketHandler defines the callbacks which are made for
  1148. * list_bucket requests.
  1149. **/
  1150. typedef struct S3ListBucketHandler
  1151. {
  1152. /**
  1153. * responseHandler provides the properties and complete callback
  1154. **/
  1155. S3ResponseHandler responseHandler;
  1156. /**
  1157. * The listBucketCallback is called as items are reported back from S3 as
  1158. * responses to the request. This may be called more than one time per
  1159. * list bucket request, each time providing more items from the list
  1160. * operation.
  1161. **/
  1162. S3ListBucketCallback *listBucketCallback;
  1163. } S3ListBucketHandler;
  1164. /**
  1165. * An S3PutObjectHandler defines the callbacks which are made for
  1166. * put_object requests.
  1167. **/
  1168. typedef struct S3PutObjectHandler
  1169. {
  1170. /**
  1171. * responseHandler provides the properties and complete callback
  1172. **/
  1173. S3ResponseHandler responseHandler;
  1174. /**
  1175. * The putObjectDataCallback is called to acquire data to send to S3 as
  1176. * the contents of the put_object request. It is made repeatedly until it
  1177. * returns a negative number (indicating that the request should be
  1178. * aborted), or 0 (indicating that all data has been supplied).
  1179. **/
  1180. S3PutObjectDataCallback *putObjectDataCallback;
  1181. } S3PutObjectHandler;
  1182. /**
  1183. * An S3GetObjectHandler defines the callbacks which are made for
  1184. * get_object requests.
  1185. **/
  1186. typedef struct S3GetObjectHandler
  1187. {
  1188. /**
  1189. * responseHandler provides the properties and complete callback
  1190. **/
  1191. S3ResponseHandler responseHandler;
  1192. /**
  1193. * The getObjectDataCallback is called as data is read from S3 as the
  1194. * contents of the object being read in the get_object request. It is
  1195. * called repeatedly until there is no more data provided in the request,
  1196. * or until the callback returns an error status indicating that the
  1197. * request should be aborted.
  1198. **/
  1199. S3GetObjectDataCallback *getObjectDataCallback;
  1200. } S3GetObjectHandler;
  1201. typedef struct S3MultipartInitialHandler {
  1202. /**
  1203. * responseHandler provides the properties and complete callback
  1204. **/
  1205. S3ResponseHandler responseHandler;
  1206. S3MultipartInitialResponseCallback *responseXmlCallback;
  1207. } S3MultipartInitialHandler;
  1208. typedef struct S3MultipartCommitHandler
  1209. {
  1210. /**
  1211. * responseHandler provides the properties and complete callback
  1212. **/
  1213. S3ResponseHandler responseHandler;
  1214. /**
  1215. * The putObjectDataCallback is called to acquire data to send to S3 as
  1216. * the contents of the put_object request. It is made repeatedly until it
  1217. * returns a negative number (indicating that the request should be
  1218. * aborted), or 0 (indicating that all data has been supplied).
  1219. **/
  1220. S3PutObjectDataCallback *putObjectDataCallback;
  1221. S3MultipartCommitResponseCallback *responseXmlCallback;
  1222. } S3MultipartCommitHandler;
  1223. typedef struct S3ListMultipartUploadsHandler
  1224. {
  1225. /**
  1226. * responseHandler provides the properties and complete callback
  1227. **/
  1228. S3ResponseHandler responseHandler;
  1229. S3ListMultipartUploadsResponseCallback *responseXmlCallback;
  1230. } S3ListMultipartUploadsHandler;
  1231. typedef struct S3ListPartsHandler
  1232. {
  1233. /**
  1234. * responseHandler provides the properties and complete callback
  1235. **/
  1236. S3ResponseHandler responseHandler;
  1237. S3ListPartsResponseCallback *responseXmlCallback;
  1238. } S3ListPartsHandler;
  1239. typedef struct S3AbortMultipartUploadHandler
  1240. {
  1241. /**
  1242. * responseHandler provides the properties and complete callback
  1243. **/
  1244. S3ResponseHandler responseHandler;
  1245. } S3AbortMultipartUploadHandler;
  1246. /** **************************************************************************
  1247. * General Library Functions
  1248. ************************************************************************** **/
  1249. /**
  1250. * Initializes libs3 for use. This function must be called before any other
  1251. * libs3 function is called. It may be called multiple times, with the same
  1252. * effect as calling it once, as long as S3_deinitialize() is called an
  1253. * equal number of times when the program has finished. This function is NOT
  1254. * thread-safe and must only be called by one thread at a time.
  1255. *
  1256. * @param userAgentInfo is a string that will be included in the User-Agent
  1257. * header of every request made to the S3 service. You may provide
  1258. * NULL or the empty string if you don't care about this. The value
  1259. * will not be copied by this function and must remain unaltered by the
  1260. * caller until S3_deinitialize() is called.
  1261. * @param flags is a bitmask of some combination of S3_INIT_XXX flag, or
  1262. * S3_INIT_ALL, indicating which of the libraries that libs3 depends
  1263. * upon should be initialized by S3_initialize(). Only if your program
  1264. * initializes one of these dependency libraries itself should anything
  1265. * other than S3_INIT_ALL be passed in for this bitmask.
  1266. *
  1267. * You should pass S3_INIT_WINSOCK if and only if your application does
  1268. * not initialize winsock elsewhere. On non-Microsoft Windows
  1269. * platforms it has no effect.
  1270. *
  1271. * As a convenience, the macro S3_INIT_ALL is provided, which will do
  1272. * all necessary initialization; however, be warned that things may
  1273. * break if your application re-initializes the dependent libraries
  1274. * later.
  1275. * @param defaultS3HostName is a string the specifies the default S3 server
  1276. * hostname to use when making S3 requests; this value is used
  1277. * whenever the hostName of an S3BucketContext is NULL. If NULL is
  1278. * passed here then the default of S3_DEFAULT_HOSTNAME will be used.
  1279. * @return One of:
  1280. * S3StatusOK on success
  1281. * S3StatusUriTooLong if the defaultS3HostName is longer than
  1282. * S3_MAX_HOSTNAME_SIZE
  1283. * S3StatusInternalError if dependent libraries could not be
  1284. * initialized
  1285. * S3StatusOutOfMemory on failure due to out of memory
  1286. **/
  1287. S3Status S3_initialize(const char *userAgentInfo, int flags,
  1288. const char *defaultS3HostName);
  1289. /**
  1290. * Must be called once per program for each call to libs3_initialize(). After
  1291. * this call is complete, no libs3 function may be called except
  1292. * S3_initialize().
  1293. **/
  1294. void S3_deinitialize();
  1295. /**
  1296. * Returns a string with the textual name of an S3Status code
  1297. *
  1298. * @param status is S3Status code for which the textual name will be returned
  1299. * @return a string with the textual name of an S3Status code
  1300. **/
  1301. const char *S3_get_status_name(S3Status status);
  1302. /**
  1303. * This function may be used to validate an S3 bucket name as being in the
  1304. * correct form for use with the S3 service. Amazon S3 limits the allowed
  1305. * characters in S3 bucket names, as well as imposing some additional rules on
  1306. * the length of bucket names and their structure. There are actually two
  1307. * limits; one for bucket names used only in path-style URIs, and a more
  1308. * strict limit used for bucket names used in virtual-host-style URIs. It is
  1309. * advisable to use only bucket names which meet the more strict requirements
  1310. * regardless of how the bucket expected to be used.
  1311. *
  1312. * This method does NOT validate that the bucket is available for use in the
  1313. * S3 service, so the return value of this function cannot be used to decide
  1314. * whether or not a bucket with the give name already exists in Amazon S3 or
  1315. * is accessible by the caller. It merely validates that the bucket name is
  1316. * valid for use with S3.
  1317. *
  1318. * @param bucketName is the bucket name to validate
  1319. * @param uriStyle gives the URI style to validate the bucket name against.
  1320. * It is advisable to always use S3UriStyleVirtuallHost.
  1321. * @return One of:
  1322. * S3StatusOK if the bucket name was validates successfully
  1323. * S3StatusConnectionFailed if the socket connection to the server
  1324. * failed
  1325. * S3StatusServerFailedVerification if the SSL certificate of the
  1326. * server could not be verified.
  1327. * S3StatusInvalidBucketNameTooLong if the bucket name exceeded the
  1328. * length limitation for the URI style, which is 255 bytes for
  1329. * path style URIs and 63 bytes for virtual host type URIs
  1330. * S3StatusInvalidBucketNameTooShort if the bucket name is less than
  1331. * 3 characters
  1332. * S3StatusInvalidBucketNameFirstCharacter if the bucket name as an
  1333. * invalid first character, which is anything other than
  1334. * an alphanumeric character
  1335. * S3StatusInvalidBucketNameCharacterSequence if the bucket name
  1336. * includes an invalid character sequence, which for virtual host
  1337. * style buckets is ".-" or "-."
  1338. * S3StatusInvalidBucketNameCharacter if the bucket name includes an
  1339. * invalid character, which is anything other than alphanumeric,
  1340. * '-', '.', or for path style URIs only, '_'.
  1341. * S3StatusInvalidBucketNameDotQuadNotation if the bucket name is in
  1342. * dot-quad notation, i.e. the form of an IP address, which is
  1343. * not allowed by Amazon S3.
  1344. **/
  1345. S3Status S3_validate_bucket_name(const char *bucketName, S3UriStyle uriStyle);
  1346. /**
  1347. * Converts an XML representation of an ACL to a libs3 structured
  1348. * representation. This method is not strictly necessary for working with
  1349. * ACLs using libs3, but may be convenient for users of the library who read
  1350. * ACLs from elsewhere in XML format and need to use these ACLs with libs3.
  1351. *
  1352. * @param aclXml is the XML representation of the ACL. This must be a
  1353. * zero-terminated character string.
  1354. * @param ownerId will be filled in with the Owner ID specified in the XML.
  1355. * At most MAX_GRANTEE_USER_ID_SIZE bytes will be stored at this
  1356. * location.
  1357. * @param ownerDisplayName will be filled in with the Owner Display Name
  1358. * specified in the XML. At most MAX_GRANTEE_DISPLAY_NAME_SIZE bytes
  1359. * will be stored at this location.
  1360. * @param aclGrantCountReturn returns the number of S3AclGrant structures
  1361. * returned in the aclGrantsReturned array
  1362. * @param aclGrants must be passed in as an array of at least S3_ACL_MAXCOUNT
  1363. * structures, and on return from this function, the first
  1364. * aclGrantCountReturn structures will be filled in with the ACLs
  1365. * represented by the input XML.
  1366. * @return One of:
  1367. * S3StatusOK on successful conversion of the ACL
  1368. * S3StatusInternalError on internal error representing a bug in the
  1369. * libs3 library
  1370. * S3StatusXmlParseFailure if the XML document was malformed
  1371. **/
  1372. S3Status S3_convert_acl(char *aclXml, char *ownerId, char *ownerDisplayName,
  1373. int *aclGrantCountReturn, S3AclGrant *aclGrants);
  1374. /**
  1375. * Returns nonzero if the status indicates that the request should be
  1376. * immediately retried, because the status indicates an error of a nature that
  1377. * is likely due to transient conditions on the local system or S3, such as
  1378. * network failures, or internal retryable errors reported by S3. Returns
  1379. * zero otherwise.
  1380. *
  1381. * @param status is the status to evaluate
  1382. * @return nonzero if the status indicates a retryable error, 0 otherwise
  1383. **/
  1384. int S3_status_is_retryable(S3Status status);
  1385. /** **************************************************************************
  1386. * Request Context Management Functions
  1387. ************************************************************************** **/
  1388. /**
  1389. * An S3RequestContext allows muliple requests to be serviced by the same
  1390. * thread simultaneously. It is an optional parameter to all libs3 request
  1391. * functions, and if provided, the request is managed by the S3RequestContext;
  1392. * if not, the request is handled synchronously and is complete when the libs3
  1393. * request function has returned.
  1394. *
  1395. * @param requestContextReturn returns the newly-created S3RequestContext
  1396. * structure, which if successfully returned, must be destroyed via a
  1397. * call to S3_destroy_request_context when it is no longer needed. If
  1398. * an error status is returned from this function, then
  1399. * requestContextReturn will not have been filled in, and
  1400. * S3_destroy_request_context should not be called on it
  1401. * @return One of:
  1402. * S3StatusOK if the request context was successfully created
  1403. * S3StatusOutOfMemory if the request context could not be created due
  1404. * to an out of memory error
  1405. **/
  1406. S3Status S3_create_request_context(S3RequestContext **requestContextReturn);
  1407. /**
  1408. * Destroys an S3RequestContext which was created with
  1409. * S3_create_request_context. Any requests which are currently being
  1410. * processed by the S3RequestContext will immediately be aborted and their
  1411. * request completed callbacks made with the status S3StatusInterrupted.
  1412. *
  1413. * @param requestContext is the S3RequestContext to destroy
  1414. **/
  1415. void S3_destroy_request_context(S3RequestContext *requestContext);
  1416. #ifdef WINSCP
  1417. struct ne_session_s;
  1418. typedef void (S3SessionCallback)(ne_session_s *session, void *callbackData);
  1419. void S3_set_request_context_session_callback(S3RequestContext *requestContext,
  1420. S3SessionCallback sessionCallback,
  1421. void * sessionCallbackData);
  1422. struct ne_ssl_certificate_s;
  1423. typedef int (S3SslCallback)(int failures, const ne_ssl_certificate_s *certificate, void *callbackData);
  1424. void S3_set_request_context_ssl_callback(S3RequestContext *requestContext,
  1425. S3SslCallback sslCallback,
  1426. void * sslCallbackData);
  1427. typedef void (S3ResponseDataCallback)(const char *data, size_t size, void *callbackData);
  1428. void S3_set_request_context_response_data_callback(S3RequestContext *requestContext,
  1429. S3ResponseDataCallback responseDataCallback,
  1430. void * responseDataCallbackData);
  1431. #else
  1432. /**
  1433. * Runs the S3RequestContext until all requests within it have completed,
  1434. * or until an error occurs.
  1435. *
  1436. * @param requestContext is the S3RequestContext to run until all requests
  1437. * within it have completed or until an error occurs
  1438. * @return One of:
  1439. * S3StatusOK if all requests were successfully run to completion
  1440. * S3StatusConnectionFailed if the socket connection to the server
  1441. * failed
  1442. * S3StatusServerFailedVerification if the SSL certificate of the
  1443. * server could not be verified.
  1444. * S3StatusInternalError if an internal error prevented the
  1445. * S3RequestContext from running one or more requests
  1446. * S3StatusOutOfMemory if requests could not be run to completion
  1447. * due to an out of memory error
  1448. **/
  1449. S3Status S3_runall_request_context(S3RequestContext *requestContext);
  1450. /**
  1451. * Does some processing of requests within the S3RequestContext. One or more
  1452. * requests may have callbacks made on them and may complete. This function
  1453. * processes any requests which have immediately available I/O, and will not
  1454. * block waiting for I/O on any request. This function would normally be used
  1455. * with S3_get_request_context_fdsets.
  1456. *
  1457. * @param requestContext is the S3RequestContext to process
  1458. * @param requestsRemainingReturn returns the number of requests remaining
  1459. * and not yet completed within the S3RequestContext after this
  1460. * function returns.
  1461. * @return One of:
  1462. * S3StatusOK if request processing proceeded without error
  1463. * S3StatusConnectionFailed if the socket connection to the server
  1464. * failed
  1465. * S3StatusServerFailedVerification if the SSL certificate of the
  1466. * server could not be verified.
  1467. * S3StatusInternalError if an internal error prevented the
  1468. * S3RequestContext from running one or more requests
  1469. * S3StatusOutOfMemory if requests could not be processed due to
  1470. * an out of memory error
  1471. **/
  1472. S3Status S3_runonce_request_context(S3RequestContext *requestContext,
  1473. int *requestsRemainingReturn);
  1474. /**
  1475. * This function, in conjunction allows callers to manually manage a set of
  1476. * requests using an S3RequestContext. This function returns the set of file
  1477. * descriptors which the caller can watch (typically using select()), along
  1478. * with any other file descriptors of interest to the caller, and using
  1479. * whatever timeout (if any) the caller wishes, until one or more file
  1480. * descriptors in the returned sets become ready for I/O, at which point
  1481. * S3_runonce_request_context can be called to process requests with available
  1482. * I/O.
  1483. *
  1484. * @param requestContext is the S3RequestContext to get fd_sets from
  1485. * @param readFdSet is a pointer to an fd_set which will have all file
  1486. * descriptors to watch for read events for the requests in the
  1487. * S3RequestContext set into it upon return. Should be zero'd out
  1488. * (using FD_ZERO) before being passed into this function.
  1489. * @param writeFdSet is a pointer to an fd_set which will have all file
  1490. * descriptors to watch for write events for the requests in the
  1491. * S3RequestContext set into it upon return. Should be zero'd out
  1492. * (using FD_ZERO) before being passed into this function.
  1493. * @param exceptFdSet is a pointer to an fd_set which will have all file
  1494. * descriptors to watch for exception events for the requests in the
  1495. * S3RequestContext set into it upon return. Should be zero'd out
  1496. * (using FD_ZERO) before being passed into this function.
  1497. * @param maxFd returns the highest file descriptor set into any of the
  1498. * fd_sets, or -1 if no file descriptors were set
  1499. * @return One of:
  1500. * S3StatusOK if all fd_sets were successfully set
  1501. * S3StatusInternalError if an internal error prevented this function
  1502. * from completing successfully
  1503. **/
  1504. S3Status S3_get_request_context_fdsets(S3RequestContext *requestContext,
  1505. fd_set *readFdSet, fd_set *writeFdSet,
  1506. fd_set *exceptFdSet, int *maxFd);
  1507. /**
  1508. * This function returns the maximum number of milliseconds that the caller of
  1509. * S3_runonce_request_context should wait on the fdsets obtained via a call to
  1510. * S3_get_request_context_fdsets. In other words, this is essentially the
  1511. * select() timeout that needs to be used (shorter values are OK, but no
  1512. * longer than this) to ensure that internal timeout code of libs3 can work
  1513. * properly. This function should be called right before select() each time
  1514. * select() on the request_context fdsets are to be performed by the libs3
  1515. * user.
  1516. *
  1517. * @param requestContext is the S3RequestContext to get the timeout from
  1518. * @return the maximum number of milliseconds to select() on fdsets. Callers
  1519. * could wait a shorter time if they wish, but not longer.
  1520. **/
  1521. int64_t S3_get_request_context_timeout(S3RequestContext *requestContext);
  1522. /**
  1523. * This function enables SSL peer certificate verification on a per-request
  1524. * context basis. If this is called, the context's value of verifyPeer will
  1525. * be used when processing requests. Otherwise, the default set by the
  1526. * flags to S3_initialize() are used.
  1527. *
  1528. * @param requestContext the S3RequestContext to set the verifyPeer flag on.
  1529. * @param verifyPeer a boolean value indicating whether to verify the peer
  1530. * certificate or not.
  1531. */
  1532. void S3_set_request_context_verify_peer(S3RequestContext *requestContext,
  1533. int verifyPeer);
  1534. #endif
  1535. /** **************************************************************************
  1536. * S3 Utility Functions
  1537. ************************************************************************** **/
  1538. /**
  1539. * Generates an HTTP authenticated query string, which may then be used by
  1540. * a browser (or other web client) to issue the request. The request is
  1541. * implicitly a GET request; Amazon S3 is documented to only support this type
  1542. * of authenticated query string request.
  1543. *
  1544. * @param buffer is the output buffer for the authenticated query string.
  1545. * It must be at least S3_MAX_AUTHENTICATED_QUERY_STRING_SIZE bytes in
  1546. * length.
  1547. * @param bucketContext gives the bucket and associated parameters for the
  1548. * request to generate.
  1549. * @param key gives the key which the authenticated request will GET.
  1550. * @param expires gives the number of seconds since Unix epoch for the
  1551. * expiration date of the request; after this time, the request will
  1552. * no longer be valid. If this value is negative, the largest
  1553. * expiration interval possible is used (one week).
  1554. * @param resource gives a sub-resource to be fetched for the request, or NULL
  1555. * for none. This should be of the form "?<resource>", i.e.
  1556. * "?torrent".
  1557. * @param httpMethod the HTTP request method that will be used with the
  1558. * generated query string (e.g. "GET").
  1559. * @return One of:
  1560. * S3StatusUriTooLong if, due to an internal error, the generated URI
  1561. * is longer than S3_MAX_AUTHENTICATED_QUERY_STRING_SIZE bytes in
  1562. * length and thus will not fit into the supplied buffer
  1563. * S3StatusOK on success
  1564. **/
  1565. S3Status S3_generate_authenticated_query_string
  1566. (char *buffer, const S3BucketContext *bucketContext,
  1567. const char *key, int expires, const char *resource,
  1568. const char *httpMethod);
  1569. /** **************************************************************************
  1570. * Service Functions
  1571. ************************************************************************** **/
  1572. /**
  1573. * Lists all S3 buckets belonging to the access key id.
  1574. *
  1575. * @param protocol gives the protocol to use for this request
  1576. * @param accessKeyId gives the Amazon Access Key ID for which to list owned
  1577. * buckets
  1578. * @param secretAccessKey gives the Amazon Secret Access Key for which to list
  1579. * owned buckets
  1580. * @param securityToken gives the security token used to generate the Temporary
  1581. * Security Credentials
  1582. * @param hostName is the S3 host name to use; if NULL is passed in, the
  1583. * default S3 host as provided to S3_initialize() will be used.
  1584. * @param authRegion is the AWS region to use for the authorization signature
  1585. * @param requestContext if non-NULL, gives the S3RequestContext to add this
  1586. * request to, and does not perform the request immediately. If NULL,
  1587. * performs the request immediately and synchronously.
  1588. * @param timeoutMs if not 0 contains total request timeout in milliseconds
  1589. * @param handler gives the callbacks to call as the request is processed and
  1590. * completed
  1591. * @param callbackData will be passed in as the callbackData parameter to
  1592. * all callbacks for this request
  1593. **/
  1594. void S3_list_service(S3Protocol protocol, const char *accessKeyId,
  1595. const char *secretAccessKey, const char *securityToken,
  1596. const char *hostName, const char *authRegion,
  1597. int maxkeys, // WINSCP
  1598. S3RequestContext *requestContext,
  1599. int timeoutMs,
  1600. const S3ListServiceHandler *handler, void *callbackData);
  1601. /** **************************************************************************
  1602. * Bucket Functions
  1603. ************************************************************************** **/
  1604. /**
  1605. * Tests the existence of an S3 bucket, additionally returning the bucket's
  1606. * location if it exists and is accessible.
  1607. *
  1608. * @param protocol gives the protocol to use for this request
  1609. * @param uriStyle gives the URI style to use for this request
  1610. * @param accessKeyId gives the Amazon Access Key ID for which to list owned
  1611. * buckets
  1612. * @param secretAccessKey gives the Amazon Secret Access Key for which to list
  1613. * owned buckets
  1614. * @param securityToken gives the security token used to generate the Temporary
  1615. * Security Credentials
  1616. * @param hostName is the S3 host name to use; if NULL is passed in, the
  1617. * default S3 host as provided to S3_initialize() will be used.
  1618. * @param bucketName is the bucket name to test
  1619. * @param authRegion is the AWS region to use for the authorization signature
  1620. * @param locationConstraintReturnSize gives the number of bytes in the
  1621. * locationConstraintReturn parameter
  1622. * @param locationConstraintReturn provides the location into which to write
  1623. * the name of the location constraint naming the geographic location
  1624. * of the S3 bucket. This must have at least as many characters in it
  1625. * as specified by locationConstraintReturn, and should start out
  1626. * NULL-terminated. On successful completion of this request, this
  1627. * will be set to the name of the geographic location of S3 bucket, or
  1628. * will be left as a zero-length string if no location was available.
  1629. * @param requestContext if non-NULL, gives the S3RequestContext to add this
  1630. * request to, and does not perform the request immediately. If NULL,
  1631. * performs the request immediately and synchronously.
  1632. * @param timeoutMs if not 0 contains total request timeout in milliseconds
  1633. * @param handler gives the callbacks to call as the request is processed and
  1634. * completed
  1635. * @param callbackData will be passed in as the callbackData parameter to
  1636. * all callbacks for this request
  1637. **/
  1638. void S3_test_bucket(S3Protocol protocol, S3UriStyle uriStyle,
  1639. const char *accessKeyId, const char *secretAccessKey,
  1640. const char *securityToken, const char *hostName,
  1641. const char *bucketName, const char *authRegion,
  1642. int locationConstraintReturnSize,
  1643. char *locationConstraintReturn,
  1644. S3RequestContext *requestContext,
  1645. int timeoutMs,
  1646. const S3ResponseHandler *handler, void *callbackData);
  1647. /**
  1648. * Creates a new bucket.
  1649. *
  1650. * @param protocol gives the protocol to use for this request
  1651. * @param accessKeyId gives the Amazon Access Key ID for which to list owned
  1652. * buckets
  1653. * @param secretAccessKey gives the Amazon Secret Access Key for which to list
  1654. * owned buckets
  1655. * @param securityToken gives the security token used to generate the Temporary
  1656. * Security Credentials
  1657. * @param hostName is the S3 host name to use; if NULL is passed in, the
  1658. * default S3 host as provided to S3_initialize() will be used.
  1659. * @param bucketName is the name of the bucket to be created
  1660. * @param authRegion is the AWS region to use for the authorization signature
  1661. * @param cannedAcl gives the "REST canned ACL" to use for the created bucket
  1662. * @param locationConstraint if non-NULL, gives the geographic location for
  1663. * the bucket to create.
  1664. * @param requestContext if non-NULL, gives the S3RequestContext to add this
  1665. * request to, and does not perform the request immediately. If NULL,
  1666. * performs the request immediately and synchronously.
  1667. * @param timeoutMs if not 0 contains total request timeout in milliseconds
  1668. * @param handler gives the callbacks to call as the request is processed and
  1669. * completed
  1670. * @param callbackData will be passed in as the callbackData parameter to
  1671. * all callbacks for this request
  1672. **/
  1673. void S3_create_bucket(S3Protocol protocol, const char *accessKeyId,
  1674. const char *secretAccessKey, const char *securityToken,
  1675. const char *hostName, const char *bucketName,
  1676. const char *authRegion, S3CannedAcl cannedAcl,
  1677. const char *locationConstraint,
  1678. S3RequestContext *requestContext,
  1679. int timeoutMs,
  1680. const S3ResponseHandler *handler, void *callbackData);
  1681. /**
  1682. * Deletes a bucket. The bucket must be empty, or the status
  1683. * S3StatusErrorBucketNotEmpty will result.
  1684. *
  1685. * @param protocol gives the protocol to use for this request
  1686. * @param uriStyle gives the URI style to use for this request
  1687. * @param accessKeyId gives the Amazon Access Key ID for which to list owned
  1688. * buckets
  1689. * @param secretAccessKey gives the Amazon Secret Access Key for which to list
  1690. * owned buckets
  1691. * @param securityToken gives the security token used to generate the Temporary
  1692. * Security Credentials
  1693. * @param hostName is the S3 host name to use; if NULL is passed in, the
  1694. * default S3 host as provided to S3_initialize() will be used.
  1695. * @param bucketName is the name of the bucket to be deleted
  1696. * @param authRegion is the AWS region to use for the authorization signature
  1697. * @param requestContext if non-NULL, gives the S3RequestContext to add this
  1698. * request to, and does not perform the request immediately. If NULL,
  1699. * performs the request immediately and synchronously.
  1700. * @param timeoutMs if not 0 contains total request timeout in milliseconds
  1701. * @param handler gives the callbacks to call as the request is processed and
  1702. * completed
  1703. * @param callbackData will be passed in as the callbackData parameter to
  1704. * all callbacks for this request
  1705. **/
  1706. void S3_delete_bucket(S3Protocol protocol, S3UriStyle uriStyle,
  1707. const char *accessKeyId, const char *secretAccessKey,
  1708. const char *securityToken, const char *hostName,
  1709. const char *bucketName, const char *authRegion,
  1710. S3RequestContext *requestContext,
  1711. int timeoutMs,
  1712. const S3ResponseHandler *handler, void *callbackData);
  1713. /**
  1714. * Lists keys within a bucket.
  1715. *
  1716. * @param bucketContext gives the bucket and associated parameters for this
  1717. * request
  1718. * @param prefix if present and non-empty, gives a prefix for matching keys
  1719. * @param marker if present and non-empty, only keys occuring after this value
  1720. * will be listed
  1721. * @param delimiter if present and non-empty, causes keys that contain the
  1722. * same string between the prefix and the first occurrence of the
  1723. * delimiter to be rolled up into a single result element
  1724. * @param maxkeys is the maximum number of keys to return
  1725. * @param requestContext if non-NULL, gives the S3RequestContext to add this
  1726. * request to, and does not perform the request immediately. If NULL,
  1727. * performs the request immediately and synchronously.
  1728. * @param timeoutMs if not 0 contains total request timeout in milliseconds
  1729. * @param handler gives the callbacks to call as the request is processed and
  1730. * completed
  1731. * @param callbackData will be passed in as the callbackData parameter to
  1732. * all callbacks for this request
  1733. **/
  1734. void S3_list_bucket(const S3BucketContext *bucketContext,
  1735. const char *prefix, const char *marker,
  1736. const char *delimiter, int maxkeys,
  1737. S3RequestContext *requestContext,
  1738. int timeoutMs,
  1739. const S3ListBucketHandler *handler, void *callbackData);
  1740. /** **************************************************************************
  1741. * Object Functions
  1742. ************************************************************************** **/
  1743. /**
  1744. * Puts object data to S3. This overwrites any existing object at that key;
  1745. * note that S3 currently only supports full-object upload. The data to
  1746. * upload will be acquired by calling the handler's putObjectDataCallback.
  1747. *
  1748. * @param bucketContext gives the bucket and associated parameters for this
  1749. * request
  1750. * @param key is the key of the object to put to
  1751. * @param contentLength is required and gives the total number of bytes that
  1752. * will be put
  1753. * @param putProperties optionally provides additional properties to apply to
  1754. * the object that is being put to
  1755. * @param requestContext if non-NULL, gives the S3RequestContext to add this
  1756. * request to, and does not perform the request immediately. If NULL,
  1757. * performs the request immediately and synchronously.
  1758. * @param timeoutMs if not 0 contains total request timeout in milliseconds
  1759. * @param handler gives the callbacks to call as the request is processed and
  1760. * completed
  1761. * @param callbackData will be passed in as the callbackData parameter to
  1762. * all callbacks for this request
  1763. **/
  1764. void S3_put_object(const S3BucketContext *bucketContext, const char *key,
  1765. uint64_t contentLength,
  1766. const S3PutProperties *putProperties,
  1767. S3RequestContext *requestContext,
  1768. int timeoutMs,
  1769. const S3PutObjectHandler *handler, void *callbackData);
  1770. /**
  1771. * Copies an object from one location to another. The object may be copied
  1772. * back to itself, which is useful for replacing metadata without changing
  1773. * the object.
  1774. *
  1775. * @param bucketContext gives the source bucket and associated parameters for
  1776. * this request
  1777. * @param key is the source key
  1778. * @param destinationBucket gives the destination bucket into which to copy
  1779. * the object. If NULL, the source bucket will be used.
  1780. * @param destinationKey gives the destination key into which to copy the
  1781. * object. If NULL, the source key will be used.
  1782. * @param putProperties optionally provides properties to apply to the object
  1783. * that is being put to. If not supplied (i.e. NULL is passed in),
  1784. * then the copied object will retain the metadata of the copied
  1785. * object.
  1786. * @param lastModifiedReturn returns the last modified date of the copied
  1787. * object
  1788. * @param eTagReturnSize specifies the number of bytes provided in the
  1789. * eTagReturn buffer
  1790. * @param eTagReturn is a buffer into which the resulting eTag of the copied
  1791. * object will be written
  1792. * @param handler gives the callbacks to call as the request is processed and
  1793. * completed
  1794. * @param callbackData will be passed in as the callbackData parameter to
  1795. * all callbacks for this request
  1796. * @param requestContext if non-NULL, gives the S3RequestContext to add this
  1797. * request to, and does not perform the request immediately. If NULL,
  1798. * performs the request immediately and synchronously.
  1799. * @param timeoutMs if not 0 contains total request timeout in milliseconds
  1800. * @param handler gives the callbacks to call as the request is processed and
  1801. * completed
  1802. * @param callbackData will be passed in as the callbackData parameter to
  1803. * all callbacks for this request
  1804. **/
  1805. void S3_copy_object(const S3BucketContext *bucketContext,
  1806. const char *key, const char *destinationBucket,
  1807. const char *destinationKey,
  1808. const S3PutProperties *putProperties,
  1809. int64_t *lastModifiedReturn, int eTagReturnSize,
  1810. char *eTagReturn, S3RequestContext *requestContext,
  1811. int timeoutMs,
  1812. const S3ResponseHandler *handler, void *callbackData);
  1813. /**
  1814. * Copies portion of an object from one location to another. The object may
  1815. * be copied back to itself, which is useful for replacing metadata without
  1816. * changing the object. Required when doing >5GB object copies.
  1817. *
  1818. * @param bucketContext gives the source bucket and associated parameters for
  1819. * this request
  1820. * @param key is the source key
  1821. * @param destinationBucket gives the destination bucket into which to copy
  1822. * the object. If NULL, the source bucket will be used.
  1823. * @param destinationKey gives the destination key into which to copy the
  1824. * object. If NULL, the source key will be used.
  1825. * @param partNo is the sequence numebr of any multipart upload, 0 = non-multipart
  1826. * @param uploadId is the ID returned for a multipart initialize request, ignored
  1827. * if partNo = 0
  1828. * @param startOffset is the starting point in original object to copy.
  1829. * @param count is the number of bytes starting at startOffset in original
  1830. * object to copy. 0 indicates no-range (i.e. all)
  1831. * @param putProperties optionally provides properties to apply to the object
  1832. * that is being put to. If not supplied (i.e. NULL is passed in),
  1833. * then the copied object will retain the metadata of the copied
  1834. * object.
  1835. * @param lastModifiedReturn returns the last modified date of the copied
  1836. * object
  1837. * @param eTagReturnSize specifies the number of bytes provided in the
  1838. * eTagReturn buffer
  1839. * @param eTagReturn is a buffer into which the resulting eTag of the copied
  1840. * object will be written
  1841. * @param handler gives the callbacks to call as the request is processed and
  1842. * completed
  1843. * @param callbackData will be passed in as the callbackData parameter to
  1844. * all callbacks for this request
  1845. * @param requestContext if non-NULL, gives the S3RequestContext to add this
  1846. * request to, and does not perform the request immediately. If NULL,
  1847. * performs the request immediately and synchronously.
  1848. * @param timeoutMs if not 0 contains total request timeout in milliseconds
  1849. * @param handler gives the callbacks to call as the request is processed and
  1850. * completed
  1851. * @param callbackData will be passed in as the callbackData parameter to
  1852. * all callbacks for this request
  1853. **/
  1854. void S3_copy_object_range(const S3BucketContext *bucketContext,
  1855. const char *key, const char *destinationBucket,
  1856. const char *destinationKey,
  1857. const int partNo, const char *uploadId,
  1858. const unsigned long startOffset, const unsigned long count,
  1859. const S3PutProperties *putProperties,
  1860. int64_t *lastModifiedReturn, int eTagReturnSize,
  1861. char *eTagReturn, S3RequestContext *requestContext,
  1862. int timeoutMs,
  1863. const S3ResponseHandler *handler, void *callbackData);
  1864. /**
  1865. * Gets an object from S3. The contents of the object are returned in the
  1866. * handler's getObjectDataCallback.
  1867. *
  1868. * @param bucketContext gives the bucket and associated parameters for this
  1869. * request
  1870. * @param key is the key of the object to get
  1871. * @param getConditions if non-NULL, gives a set of conditions which must be
  1872. * met in order for the request to succeed
  1873. * @param startByte gives the start byte for the byte range of the contents
  1874. * to be returned
  1875. * @param byteCount gives the number of bytes to return; a value of 0
  1876. * indicates that the contents up to the end should be returned
  1877. * @param requestContext if non-NULL, gives the S3RequestContext to add this
  1878. * request to, and does not perform the request immediately. If NULL,
  1879. * performs the request immediately and synchronously.
  1880. * @param timeoutMs if not 0 contains total request timeout in milliseconds
  1881. * @param handler gives the callbacks to call as the request is processed and
  1882. * completed
  1883. * @param callbackData will be passed in as the callbackData parameter to
  1884. * all callbacks for this request
  1885. **/
  1886. void S3_get_object(const S3BucketContext *bucketContext, const char *key,
  1887. const S3GetConditions *getConditions,
  1888. uint64_t startByte, uint64_t byteCount,
  1889. S3RequestContext *requestContext,
  1890. int timeoutMs,
  1891. const S3GetObjectHandler *handler, void *callbackData);
  1892. /**
  1893. * Gets the response properties for the object, but not the object contents.
  1894. *
  1895. * @param bucketContext gives the bucket and associated parameters for this
  1896. * request
  1897. * @param key is the key of the object to get the properties of
  1898. * @param requestContext if non-NULL, gives the S3RequestContext to add this
  1899. * request to, and does not perform the request immediately. If NULL,
  1900. * performs the request immediately and synchronously.
  1901. * @param timeoutMs if not 0 contains total request timeout in milliseconds
  1902. * @param handler gives the callbacks to call as the request is processed and
  1903. * completed
  1904. * @param callbackData will be passed in as the callbackData parameter to
  1905. * all callbacks for this request
  1906. **/
  1907. void S3_head_object(const S3BucketContext *bucketContext, const char *key,
  1908. S3RequestContext *requestContext,
  1909. int timeoutMs,
  1910. const S3ResponseHandler *handler, void *callbackData);
  1911. /**
  1912. * Deletes an object from S3.
  1913. *
  1914. * @param bucketContext gives the bucket and associated parameters for this
  1915. * request
  1916. * @param key is the key of the object to delete
  1917. * @param requestContext if non-NULL, gives the S3RequestContext to add this
  1918. * request to, and does not perform the request immediately. If NULL,
  1919. * performs the request immediately and synchronously.
  1920. * @param timeoutMs if not 0 contains total request timeout in milliseconds
  1921. * @param handler gives the callbacks to call as the request is processed and
  1922. * completed
  1923. * @param callbackData will be passed in as the callbackData parameter to
  1924. * all callbacks for this request
  1925. **/
  1926. void S3_delete_object(const S3BucketContext *bucketContext, const char *key,
  1927. S3RequestContext *requestContext,
  1928. int timeoutMs,
  1929. const S3ResponseHandler *handler, void *callbackData);
  1930. /** **************************************************************************
  1931. * Access Control List Functions
  1932. ************************************************************************** **/
  1933. /**
  1934. * Gets the ACL for the given bucket or object.
  1935. *
  1936. * @param bucketContext gives the bucket and associated parameters for this
  1937. * request
  1938. * @param key is the key of the object to get the ACL of; or NULL to get the
  1939. * ACL of the bucket
  1940. * @param ownerId must be supplied as a buffer of at least
  1941. * S3_MAX_GRANTEE_USER_ID_SIZE bytes, and will be filled in with the
  1942. * owner ID of the object/bucket
  1943. * @param ownerDisplayName must be supplied as a buffer of at least
  1944. * S3_MAX_GRANTEE_DISPLAY_NAME_SIZE bytes, and will be filled in with
  1945. * the display name of the object/bucket
  1946. * @param aclGrantCountReturn returns the number of S3AclGrant structures
  1947. * returned in the aclGrants parameter
  1948. * @param aclGrants must be passed in as an array of at least
  1949. * S3_MAX_ACL_GRANT_COUNT S3AclGrant structures, which will be filled
  1950. * in with the grant information for the ACL
  1951. * @param requestContext if non-NULL, gives the S3RequestContext to add this
  1952. * request to, and does not perform the request immediately. If NULL,
  1953. * performs the request immediately and synchronously.
  1954. * @param timeoutMs if not 0 contains total request timeout in milliseconds
  1955. * @param handler gives the callbacks to call as the request is processed and
  1956. * completed
  1957. * @param callbackData will be passed in as the callbackData parameter to
  1958. * all callbacks for this request
  1959. **/
  1960. void S3_get_acl(const S3BucketContext *bucketContext, const char *key,
  1961. char *ownerId, char *ownerDisplayName,
  1962. int *aclGrantCountReturn, S3AclGrant *aclGrants,
  1963. S3RequestContext *requestContext,
  1964. int timeoutMs,
  1965. const S3ResponseHandler *handler, void *callbackData);
  1966. /**
  1967. * Sets the ACL for the given bucket or object.
  1968. *
  1969. * @param bucketContext gives the bucket and associated parameters for this
  1970. * request
  1971. * @param key is the key of the object to set the ACL for; or NULL to set the
  1972. * ACL for the bucket
  1973. * @param ownerId is the owner ID of the object/bucket. Unfortunately, S3
  1974. * requires this to be valid and thus it must have been fetched by a
  1975. * previous S3 request, such as a list_buckets request.
  1976. * @param ownerDisplayName is the owner display name of the object/bucket.
  1977. * Unfortunately, S3 requires this to be valid and thus it must have
  1978. * been fetched by a previous S3 request, such as a list_buckets
  1979. * request.
  1980. * @param aclGrantCount is the number of ACL grants to set for the
  1981. * object/bucket
  1982. * @param aclGrants are the ACL grants to set for the object/bucket
  1983. * @param requestContext if non-NULL, gives the S3RequestContext to add this
  1984. * request to, and does not perform the request immediately. If NULL,
  1985. * performs the request immediately and synchronously.
  1986. * @param timeoutMs if not 0 contains total request timeout in milliseconds
  1987. * @param handler gives the callbacks to call as the request is processed and
  1988. * completed
  1989. * @param callbackData will be passed in as the callbackData parameter to
  1990. * all callbacks for this request
  1991. **/
  1992. void S3_set_acl(const S3BucketContext *bucketContext, const char *key,
  1993. const char *ownerId, const char *ownerDisplayName,
  1994. int aclGrantCount, const S3AclGrant *aclGrants,
  1995. S3RequestContext *requestContext,
  1996. int timeoutMs,
  1997. const S3ResponseHandler *handler, void *callbackData);
  1998. /** **************************************************************************
  1999. * Lifecycle Control Functions
  2000. ************************************************************************** **/
  2001. /**
  2002. * Gets the lifecycle for the given bucket
  2003. *
  2004. * @param bucketContext gives the bucket and associated parameters for this
  2005. * request
  2006. * @param lifecycleXmlDocumentReturn buffer for lifecycle XML document
  2007. * @param lifecycleXmlDocumentBufferSize size of the buffer
  2008. * @param requestContext if non-NULL, gives the S3RequestContext to add this
  2009. * request to, and does not perform the request immediately. If NULL,
  2010. * performs the request immediately and synchronously.
  2011. * @param timeoutMs if not 0 contains total request timeout in milliseconds
  2012. * @param handler gives the callbacks to call as the request is processed and
  2013. * completed
  2014. * @param callbackData will be passed in as the callbackData parameter to
  2015. * all callbacks for this request
  2016. **/
  2017. void S3_get_lifecycle(const S3BucketContext *bucketContext,
  2018. char *lifecycleXmlDocumentReturn, int lifecycleXmlDocumentBufferSize,
  2019. S3RequestContext *requestContext,
  2020. int timeoutMs,
  2021. const S3ResponseHandler *handler, void *callbackData);
  2022. /**
  2023. * Sets the lifecycle for the given bucket
  2024. *
  2025. * @param bucketContext gives the bucket and associated parameters for this
  2026. * request
  2027. * @param lifecycleXmlDocument Lifecycle configuration as an XML document
  2028. * @param requestContext if non-NULL, gives the S3RequestContext to add this
  2029. * request to, and does not perform the request immediately. If NULL,
  2030. * performs the request immediately and synchronously.
  2031. * @param timeoutMs if not 0 contains total request timeout in milliseconds
  2032. * @param handler gives the callbacks to call as the request is processed and
  2033. * completed
  2034. * @param callbackData will be passed in as the callbackData parameter to
  2035. * all callbacks for this request
  2036. **/
  2037. void S3_set_lifecycle(const S3BucketContext *bucketContext,
  2038. const char *lifecycleXmlDocument,
  2039. S3RequestContext *requestContext,
  2040. int timeoutMs,
  2041. const S3ResponseHandler *handler, void *callbackData);
  2042. /** **************************************************************************
  2043. * Server Access Log Functions
  2044. ************************************************************************** **/
  2045. /**
  2046. * Gets the service access logging settings for a bucket. The service access
  2047. * logging settings specify whether or not the S3 service will write service
  2048. * access logs for requests made for the given bucket, and if so, several
  2049. * settings controlling how these logs will be written.
  2050. *
  2051. * @param bucketContext gives the bucket and associated parameters for this
  2052. * request; this is the bucket for which service access logging is
  2053. * being requested
  2054. * @param targetBucketReturn must be passed in as a buffer of at least
  2055. * (S3_MAX_BUCKET_NAME_SIZE + 1) bytes in length, and will be filled
  2056. * in with the target bucket name for access logging for the given
  2057. * bucket, which is the bucket into which access logs for the specified
  2058. * bucket will be written. This is returned as an empty string if
  2059. * service access logging is not enabled for the given bucket.
  2060. * @param targetPrefixReturn must be passed in as a buffer of at least
  2061. * (S3_MAX_KEY_SIZE + 1) bytes in length, and will be filled in
  2062. * with the key prefix for server access logs for the given bucket,
  2063. * or the empty string if no such prefix is specified.
  2064. * @param aclGrantCountReturn returns the number of ACL grants that are
  2065. * associated with the server access logging for the given bucket.
  2066. * @param aclGrants must be passed in as an array of at least
  2067. * S3_MAX_ACL_GRANT_COUNT S3AclGrant structures, and these will be
  2068. * filled in with the target grants associated with the server access
  2069. * logging for the given bucket, whose number is returned in the
  2070. * aclGrantCountReturn parameter. These grants will be applied to the
  2071. * ACL of any server access logging log files generated by the S3
  2072. * service for the given bucket.
  2073. * @param requestContext if non-NULL, gives the S3RequestContext to add this
  2074. * request to, and does not perform the request immediately. If NULL,
  2075. * performs the request immediately and synchronously.
  2076. * @param timeoutMs if not 0 contains total request timeout in milliseconds
  2077. * @param handler gives the callbacks to call as the request is processed and
  2078. * completed
  2079. * @param callbackData will be passed in as the callbackData parameter to
  2080. * all callbacks for this request
  2081. **/
  2082. void S3_get_server_access_logging(const S3BucketContext *bucketContext,
  2083. char *targetBucketReturn,
  2084. char *targetPrefixReturn,
  2085. int *aclGrantCountReturn,
  2086. S3AclGrant *aclGrants,
  2087. S3RequestContext *requestContext,
  2088. int timeoutMs,
  2089. const S3ResponseHandler *handler,
  2090. void *callbackData);
  2091. /**
  2092. * Sets the service access logging settings for a bucket. The service access
  2093. * logging settings specify whether or not the S3 service will write service
  2094. * access logs for requests made for the given bucket, and if so, several
  2095. * settings controlling how these logs will be written.
  2096. *
  2097. * @param bucketContext gives the bucket and associated parameters for this
  2098. * request; this is the bucket for which service access logging is
  2099. * being set
  2100. * @param targetBucket gives the target bucket name for access logging for the
  2101. * given bucket, which is the bucket into which access logs for the
  2102. * specified bucket will be written.
  2103. * @param targetPrefix is an option parameter which specifies the key prefix
  2104. * for server access logs for the given bucket, or NULL if no such
  2105. * prefix is to be used.
  2106. * @param aclGrantCount specifies the number of ACL grants that are to be
  2107. * associated with the server access logging for the given bucket.
  2108. * @param aclGrants is as an array of S3AclGrant structures, whose number is
  2109. * given by the aclGrantCount parameter. These grants will be applied
  2110. * to the ACL of any server access logging log files generated by the
  2111. * S3 service for the given bucket.
  2112. * @param requestContext if non-NULL, gives the S3RequestContext to add this
  2113. * request to, and does not perform the request immediately. If NULL,
  2114. * performs the request immediately and synchronously.
  2115. * @param timeoutMs if not 0 contains total request timeout in milliseconds
  2116. * @param handler gives the callbacks to call as the request is processed and
  2117. * completed
  2118. * @param callbackData will be passed in as the callbackData parameter to
  2119. * all callbacks for this request
  2120. **/
  2121. void S3_set_server_access_logging(const S3BucketContext *bucketContext,
  2122. const char *targetBucket,
  2123. const char *targetPrefix, int aclGrantCount,
  2124. const S3AclGrant *aclGrants,
  2125. S3RequestContext *requestContext,
  2126. int timeoutMs,
  2127. const S3ResponseHandler *handler,
  2128. void *callbackData);
  2129. /**
  2130. * This operation initiates a multipart upload and returns an upload ID.
  2131. * This upload ID is used to associate all the parts in the specific
  2132. * multipart upload. You specify this upload ID in each of your subsequent
  2133. * upload part requests
  2134. *
  2135. * @param bucketContext gives the bucket and associated parameters for this
  2136. * request; this is the bucket for which service access logging is
  2137. * being set
  2138. * @param key is the source key
  2139. * @param putProperties optionally provides additional properties to apply to
  2140. * the object that is being put to
  2141. * @param handler gives the callbacks to call as the request is processed and
  2142. * completed
  2143. * @param requestContext if non-NULL, gives the S3RequestContext to add this
  2144. * request to, and does not perform the request immediately. If NULL,
  2145. * performs the request immediately and synchronously.
  2146. * @param timeoutMs if not 0 contains total request timeout in milliseconds
  2147. * @param callbackData will be passed in as the callbackData parameter to
  2148. * all callbacks for this request
  2149. **/
  2150. void S3_initiate_multipart(S3BucketContext *bucketContext, const char *key,
  2151. S3PutProperties *putProperties,
  2152. S3MultipartInitialHandler *handler,
  2153. S3RequestContext *requestContext,
  2154. int timeoutMs,
  2155. void *callbackData);
  2156. /**
  2157. * This operation uploads a part in a multipart upload.
  2158. *
  2159. * @param bucketContext gives the bucket and associated parameters for this
  2160. * request; this is the bucket for which service access logging is
  2161. * being set
  2162. * @param key is the source key
  2163. * @param putProperties optionally provides additional properties to apply to
  2164. * the object that is being put to
  2165. * @param handler gives the callbacks to call as the request is processed and
  2166. * completed
  2167. * @param seq is a part number uniquely identifies a part and also
  2168. * defines its position within the object being created.
  2169. * @param upload_id get from S3_initiate_multipart return
  2170. * @param partContentLength gives the size of the part, in bytes
  2171. * @param requestContext if non-NULL, gives the S3RequestContext to add this
  2172. * request to, and does not perform the request immediately. If NULL,
  2173. * performs the request immediately and synchronously.
  2174. * @param timeoutMs if not 0 contains total request timeout in milliseconds
  2175. * @param callbackData will be passed in as the callbackData parameter to
  2176. * all callbacks for this request
  2177. **/
  2178. void S3_upload_part(S3BucketContext *bucketContext, const char *key,
  2179. S3PutProperties * putProperties,
  2180. S3PutObjectHandler *handler,
  2181. int seq, const char *upload_id, int partContentLength,
  2182. S3RequestContext *requestContext,
  2183. int timeoutMs,
  2184. void *callbackData);
  2185. /**
  2186. * This operation completes a multipart upload by assembling previously
  2187. * uploaded parts.
  2188. *
  2189. * @param bucketContext gives the bucket and associated parameters for this
  2190. * request; this is the bucket for which service access logging is
  2191. * being set
  2192. * @param key is the source key
  2193. * @param handler gives the callbacks to call as the request is processed and
  2194. * completed
  2195. * @param upload_id get from S3_initiate_multipart return
  2196. * @param contentLength gives the total size of the commit message, in bytes
  2197. * @param requestContext if non-NULL, gives the S3RequestContext to add this
  2198. * request to, and does not perform the request immediately. If NULL,
  2199. * performs the request immediately and synchronously.
  2200. * @param timeoutMs if not 0 contains total request timeout in milliseconds
  2201. * @param callbackData will be passed in as the callbackData parameter to
  2202. * all callbacks for this request
  2203. **/
  2204. void S3_complete_multipart_upload(S3BucketContext *bucketContext,
  2205. const char *key,
  2206. S3MultipartCommitHandler *handler,
  2207. const char *upload_id,
  2208. int contentLength,
  2209. S3RequestContext *requestContext,
  2210. int timeoutMs,
  2211. void *callbackData);
  2212. /**
  2213. * This operation lists the parts that have been uploaded for a specific
  2214. * multipart upload.
  2215. *
  2216. * @param bucketContext gives the bucket and associated parameters for this
  2217. * request; this is the bucket for which service access logging is
  2218. * being set
  2219. * @param key is the source key
  2220. * @param partnumbermarker if present and non-empty, specifies the part after
  2221. * which listing should begin. Only parts with higher part numbers
  2222. * will be listed.
  2223. * @param uploadid identifying the multipart upload whose parts are being
  2224. * listed.
  2225. * @param encodingtype if present and non-empty, requests Amazon S3 to encode
  2226. * the response and specifies the encoding method to use.
  2227. * @param maxparts Sets the maximum number of parts to return in the response
  2228. * body. Default: 1,000
  2229. * @param requestContext if non-NULL, gives the S3RequestContext to add this
  2230. * request to, and does not perform the request immediately. If NULL,
  2231. * performs the request immediately and synchronously.
  2232. * @param timeoutMs if not 0 contains total request timeout in milliseconds
  2233. * @param handler gives the callbacks to call as the request is processed and
  2234. * completed
  2235. * @param callbackData will be passed in as the callbackData parameter to
  2236. * all callbacks for this request
  2237. **/
  2238. void S3_list_parts(S3BucketContext *bucketContext, const char *key,
  2239. const char *partnumbermarker,
  2240. const char *uploadid, const char *encodingtype,
  2241. int maxparts, S3RequestContext *requestContext,
  2242. int timeoutMs,
  2243. const S3ListPartsHandler *handler, void *callbackData);
  2244. /**
  2245. * This operation aborts a multipart upload. After a multipart upload is
  2246. * aborted, no additional parts can be uploaded using that upload ID.
  2247. *
  2248. * @param bucketContext gives the bucket and associated parameters for this
  2249. * request; this is the bucket for which service access logging is
  2250. * being set
  2251. * @param key is the source key
  2252. * @param uploadId identifying the multipart upload whose parts are being
  2253. * listed.
  2254. * @param timeoutMs if not 0 contains total request timeout in milliseconds
  2255. * @param handler gives the callbacks to call as the request is processed and
  2256. * completed
  2257. **/
  2258. void S3_abort_multipart_upload(S3BucketContext *bucketContext, const char *key,
  2259. const char *uploadId,
  2260. int timeoutMs,
  2261. S3AbortMultipartUploadHandler *handler,
  2262. S3RequestContext *requestContext, // WINSCP
  2263. void *callbackData); // WINSCP
  2264. /**
  2265. * This operation lists in-progress multipart uploads. An in-progress
  2266. * multipart upload is a multipart upload that has been initiated,
  2267. * using the Initiate Multipart Upload request, but has not yet been
  2268. * completed or aborted.
  2269. *
  2270. * @param bucketContext gives the bucket and associated parameters for this
  2271. * request; this is the bucket for which service access logging is
  2272. * being set
  2273. * @param prefix if present and non-empty, lists in-progress uploads only for
  2274. * those keys that begin with the specified prefix.
  2275. * @param keymarker if present and non-empty, together with upload-id-marker,
  2276. * this parameter specifies the multipart upload after which listing
  2277. * should begin.
  2278. * @param uploadidmarker if present and non-empty, together with key-marker,
  2279. * specifies the multipart upload after which listing should begin.
  2280. * @param encodingtype if present and non-empty, requests Amazon S3 to encode
  2281. * the response and specifies the encoding method to use.
  2282. * @param delimiter if present and non-empty, is the character you use to
  2283. * group keys.
  2284. * @param maxuploads sets the maximum number of multipart uploads,
  2285. * from 1 to 1,000, to return in the response body.
  2286. * @param requestContext if non-NULL, gives the S3RequestContext to add this
  2287. * request to, and does not perform the request immediately. If NULL,
  2288. * performs the request immediately and synchronously.
  2289. * @param timeoutMs if not 0 contains total request timeout in milliseconds
  2290. * @param handler gives the callbacks to call as the request is processed and
  2291. * completed
  2292. * @param callbackData will be passed in as the callbackData parameter to
  2293. * all callbacks for this request
  2294. **/
  2295. void S3_list_multipart_uploads(S3BucketContext *bucketContext,
  2296. const char *prefix, const char *keymarker,
  2297. const char *uploadidmarker,
  2298. const char *encodingtype, const char *delimiter,
  2299. int maxuploads, S3RequestContext *requestContext,
  2300. int timeoutMs,
  2301. const S3ListMultipartUploadsHandler *handler,
  2302. void *callbackData);
  2303. #ifdef WINSCP
  2304. int snprintf_S(char * s, size_t n, const char * format, size_t len, const char * data);
  2305. #endif
  2306. #ifdef __cplusplus
  2307. }
  2308. #endif
  2309. #endif /* LIBS3_H */