libs3.h 109 KB

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