examples_test.go 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package s3_test
  3. import (
  4. "bytes"
  5. "fmt"
  6. "time"
  7. "github.com/aws/aws-sdk-go/aws"
  8. "github.com/aws/aws-sdk-go/service/s3"
  9. )
  10. var _ time.Duration
  11. var _ bytes.Buffer
  12. func ExampleS3_AbortMultipartUpload() {
  13. svc := s3.New(nil)
  14. params := &s3.AbortMultipartUploadInput{
  15. Bucket: aws.String("BucketName"), // Required
  16. Key: aws.String("ObjectKey"), // Required
  17. UploadId: aws.String("MultipartUploadId"), // Required
  18. RequestPayer: aws.String("RequestPayer"),
  19. }
  20. resp, err := svc.AbortMultipartUpload(params)
  21. if err != nil {
  22. // Print the error, cast err to awserr.Error to get the Code and
  23. // Message from an error.
  24. fmt.Println(err.Error())
  25. return
  26. }
  27. // Pretty-print the response data.
  28. fmt.Println(resp)
  29. }
  30. func ExampleS3_CompleteMultipartUpload() {
  31. svc := s3.New(nil)
  32. params := &s3.CompleteMultipartUploadInput{
  33. Bucket: aws.String("BucketName"), // Required
  34. Key: aws.String("ObjectKey"), // Required
  35. UploadId: aws.String("MultipartUploadId"), // Required
  36. MultipartUpload: &s3.CompletedMultipartUpload{
  37. Parts: []*s3.CompletedPart{
  38. { // Required
  39. ETag: aws.String("ETag"),
  40. PartNumber: aws.Int64(1),
  41. },
  42. // More values...
  43. },
  44. },
  45. RequestPayer: aws.String("RequestPayer"),
  46. }
  47. resp, err := svc.CompleteMultipartUpload(params)
  48. if err != nil {
  49. // Print the error, cast err to awserr.Error to get the Code and
  50. // Message from an error.
  51. fmt.Println(err.Error())
  52. return
  53. }
  54. // Pretty-print the response data.
  55. fmt.Println(resp)
  56. }
  57. func ExampleS3_CopyObject() {
  58. svc := s3.New(nil)
  59. params := &s3.CopyObjectInput{
  60. Bucket: aws.String("BucketName"), // Required
  61. CopySource: aws.String("CopySource"), // Required
  62. Key: aws.String("ObjectKey"), // Required
  63. ACL: aws.String("ObjectCannedACL"),
  64. CacheControl: aws.String("CacheControl"),
  65. ContentDisposition: aws.String("ContentDisposition"),
  66. ContentEncoding: aws.String("ContentEncoding"),
  67. ContentLanguage: aws.String("ContentLanguage"),
  68. ContentType: aws.String("ContentType"),
  69. CopySourceIfMatch: aws.String("CopySourceIfMatch"),
  70. CopySourceIfModifiedSince: aws.Time(time.Now()),
  71. CopySourceIfNoneMatch: aws.String("CopySourceIfNoneMatch"),
  72. CopySourceIfUnmodifiedSince: aws.Time(time.Now()),
  73. CopySourceSSECustomerAlgorithm: aws.String("CopySourceSSECustomerAlgorithm"),
  74. CopySourceSSECustomerKey: aws.String("CopySourceSSECustomerKey"),
  75. CopySourceSSECustomerKeyMD5: aws.String("CopySourceSSECustomerKeyMD5"),
  76. Expires: aws.Time(time.Now()),
  77. GrantFullControl: aws.String("GrantFullControl"),
  78. GrantRead: aws.String("GrantRead"),
  79. GrantReadACP: aws.String("GrantReadACP"),
  80. GrantWriteACP: aws.String("GrantWriteACP"),
  81. Metadata: map[string]*string{
  82. "Key": aws.String("MetadataValue"), // Required
  83. // More values...
  84. },
  85. MetadataDirective: aws.String("MetadataDirective"),
  86. RequestPayer: aws.String("RequestPayer"),
  87. SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
  88. SSECustomerKey: aws.String("SSECustomerKey"),
  89. SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
  90. SSEKMSKeyId: aws.String("SSEKMSKeyId"),
  91. ServerSideEncryption: aws.String("ServerSideEncryption"),
  92. StorageClass: aws.String("StorageClass"),
  93. WebsiteRedirectLocation: aws.String("WebsiteRedirectLocation"),
  94. }
  95. resp, err := svc.CopyObject(params)
  96. if err != nil {
  97. // Print the error, cast err to awserr.Error to get the Code and
  98. // Message from an error.
  99. fmt.Println(err.Error())
  100. return
  101. }
  102. // Pretty-print the response data.
  103. fmt.Println(resp)
  104. }
  105. func ExampleS3_CreateBucket() {
  106. svc := s3.New(nil)
  107. params := &s3.CreateBucketInput{
  108. Bucket: aws.String("BucketName"), // Required
  109. ACL: aws.String("BucketCannedACL"),
  110. CreateBucketConfiguration: &s3.CreateBucketConfiguration{
  111. LocationConstraint: aws.String("BucketLocationConstraint"),
  112. },
  113. GrantFullControl: aws.String("GrantFullControl"),
  114. GrantRead: aws.String("GrantRead"),
  115. GrantReadACP: aws.String("GrantReadACP"),
  116. GrantWrite: aws.String("GrantWrite"),
  117. GrantWriteACP: aws.String("GrantWriteACP"),
  118. }
  119. resp, err := svc.CreateBucket(params)
  120. if err != nil {
  121. // Print the error, cast err to awserr.Error to get the Code and
  122. // Message from an error.
  123. fmt.Println(err.Error())
  124. return
  125. }
  126. // Pretty-print the response data.
  127. fmt.Println(resp)
  128. }
  129. func ExampleS3_CreateMultipartUpload() {
  130. svc := s3.New(nil)
  131. params := &s3.CreateMultipartUploadInput{
  132. Bucket: aws.String("BucketName"), // Required
  133. Key: aws.String("ObjectKey"), // Required
  134. ACL: aws.String("ObjectCannedACL"),
  135. CacheControl: aws.String("CacheControl"),
  136. ContentDisposition: aws.String("ContentDisposition"),
  137. ContentEncoding: aws.String("ContentEncoding"),
  138. ContentLanguage: aws.String("ContentLanguage"),
  139. ContentType: aws.String("ContentType"),
  140. Expires: aws.Time(time.Now()),
  141. GrantFullControl: aws.String("GrantFullControl"),
  142. GrantRead: aws.String("GrantRead"),
  143. GrantReadACP: aws.String("GrantReadACP"),
  144. GrantWriteACP: aws.String("GrantWriteACP"),
  145. Metadata: map[string]*string{
  146. "Key": aws.String("MetadataValue"), // Required
  147. // More values...
  148. },
  149. RequestPayer: aws.String("RequestPayer"),
  150. SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
  151. SSECustomerKey: aws.String("SSECustomerKey"),
  152. SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
  153. SSEKMSKeyId: aws.String("SSEKMSKeyId"),
  154. ServerSideEncryption: aws.String("ServerSideEncryption"),
  155. StorageClass: aws.String("StorageClass"),
  156. WebsiteRedirectLocation: aws.String("WebsiteRedirectLocation"),
  157. }
  158. resp, err := svc.CreateMultipartUpload(params)
  159. if err != nil {
  160. // Print the error, cast err to awserr.Error to get the Code and
  161. // Message from an error.
  162. fmt.Println(err.Error())
  163. return
  164. }
  165. // Pretty-print the response data.
  166. fmt.Println(resp)
  167. }
  168. func ExampleS3_DeleteBucket() {
  169. svc := s3.New(nil)
  170. params := &s3.DeleteBucketInput{
  171. Bucket: aws.String("BucketName"), // Required
  172. }
  173. resp, err := svc.DeleteBucket(params)
  174. if err != nil {
  175. // Print the error, cast err to awserr.Error to get the Code and
  176. // Message from an error.
  177. fmt.Println(err.Error())
  178. return
  179. }
  180. // Pretty-print the response data.
  181. fmt.Println(resp)
  182. }
  183. func ExampleS3_DeleteBucketCors() {
  184. svc := s3.New(nil)
  185. params := &s3.DeleteBucketCorsInput{
  186. Bucket: aws.String("BucketName"), // Required
  187. }
  188. resp, err := svc.DeleteBucketCors(params)
  189. if err != nil {
  190. // Print the error, cast err to awserr.Error to get the Code and
  191. // Message from an error.
  192. fmt.Println(err.Error())
  193. return
  194. }
  195. // Pretty-print the response data.
  196. fmt.Println(resp)
  197. }
  198. func ExampleS3_DeleteBucketLifecycle() {
  199. svc := s3.New(nil)
  200. params := &s3.DeleteBucketLifecycleInput{
  201. Bucket: aws.String("BucketName"), // Required
  202. }
  203. resp, err := svc.DeleteBucketLifecycle(params)
  204. if err != nil {
  205. // Print the error, cast err to awserr.Error to get the Code and
  206. // Message from an error.
  207. fmt.Println(err.Error())
  208. return
  209. }
  210. // Pretty-print the response data.
  211. fmt.Println(resp)
  212. }
  213. func ExampleS3_DeleteBucketPolicy() {
  214. svc := s3.New(nil)
  215. params := &s3.DeleteBucketPolicyInput{
  216. Bucket: aws.String("BucketName"), // Required
  217. }
  218. resp, err := svc.DeleteBucketPolicy(params)
  219. if err != nil {
  220. // Print the error, cast err to awserr.Error to get the Code and
  221. // Message from an error.
  222. fmt.Println(err.Error())
  223. return
  224. }
  225. // Pretty-print the response data.
  226. fmt.Println(resp)
  227. }
  228. func ExampleS3_DeleteBucketReplication() {
  229. svc := s3.New(nil)
  230. params := &s3.DeleteBucketReplicationInput{
  231. Bucket: aws.String("BucketName"), // Required
  232. }
  233. resp, err := svc.DeleteBucketReplication(params)
  234. if err != nil {
  235. // Print the error, cast err to awserr.Error to get the Code and
  236. // Message from an error.
  237. fmt.Println(err.Error())
  238. return
  239. }
  240. // Pretty-print the response data.
  241. fmt.Println(resp)
  242. }
  243. func ExampleS3_DeleteBucketTagging() {
  244. svc := s3.New(nil)
  245. params := &s3.DeleteBucketTaggingInput{
  246. Bucket: aws.String("BucketName"), // Required
  247. }
  248. resp, err := svc.DeleteBucketTagging(params)
  249. if err != nil {
  250. // Print the error, cast err to awserr.Error to get the Code and
  251. // Message from an error.
  252. fmt.Println(err.Error())
  253. return
  254. }
  255. // Pretty-print the response data.
  256. fmt.Println(resp)
  257. }
  258. func ExampleS3_DeleteBucketWebsite() {
  259. svc := s3.New(nil)
  260. params := &s3.DeleteBucketWebsiteInput{
  261. Bucket: aws.String("BucketName"), // Required
  262. }
  263. resp, err := svc.DeleteBucketWebsite(params)
  264. if err != nil {
  265. // Print the error, cast err to awserr.Error to get the Code and
  266. // Message from an error.
  267. fmt.Println(err.Error())
  268. return
  269. }
  270. // Pretty-print the response data.
  271. fmt.Println(resp)
  272. }
  273. func ExampleS3_DeleteObject() {
  274. svc := s3.New(nil)
  275. params := &s3.DeleteObjectInput{
  276. Bucket: aws.String("BucketName"), // Required
  277. Key: aws.String("ObjectKey"), // Required
  278. MFA: aws.String("MFA"),
  279. RequestPayer: aws.String("RequestPayer"),
  280. VersionId: aws.String("ObjectVersionId"),
  281. }
  282. resp, err := svc.DeleteObject(params)
  283. if err != nil {
  284. // Print the error, cast err to awserr.Error to get the Code and
  285. // Message from an error.
  286. fmt.Println(err.Error())
  287. return
  288. }
  289. // Pretty-print the response data.
  290. fmt.Println(resp)
  291. }
  292. func ExampleS3_DeleteObjects() {
  293. svc := s3.New(nil)
  294. params := &s3.DeleteObjectsInput{
  295. Bucket: aws.String("BucketName"), // Required
  296. Delete: &s3.Delete{ // Required
  297. Objects: []*s3.ObjectIdentifier{ // Required
  298. { // Required
  299. Key: aws.String("ObjectKey"), // Required
  300. VersionId: aws.String("ObjectVersionId"),
  301. },
  302. // More values...
  303. },
  304. Quiet: aws.Bool(true),
  305. },
  306. MFA: aws.String("MFA"),
  307. RequestPayer: aws.String("RequestPayer"),
  308. }
  309. resp, err := svc.DeleteObjects(params)
  310. if err != nil {
  311. // Print the error, cast err to awserr.Error to get the Code and
  312. // Message from an error.
  313. fmt.Println(err.Error())
  314. return
  315. }
  316. // Pretty-print the response data.
  317. fmt.Println(resp)
  318. }
  319. func ExampleS3_GetBucketAcl() {
  320. svc := s3.New(nil)
  321. params := &s3.GetBucketAclInput{
  322. Bucket: aws.String("BucketName"), // Required
  323. }
  324. resp, err := svc.GetBucketAcl(params)
  325. if err != nil {
  326. // Print the error, cast err to awserr.Error to get the Code and
  327. // Message from an error.
  328. fmt.Println(err.Error())
  329. return
  330. }
  331. // Pretty-print the response data.
  332. fmt.Println(resp)
  333. }
  334. func ExampleS3_GetBucketCors() {
  335. svc := s3.New(nil)
  336. params := &s3.GetBucketCorsInput{
  337. Bucket: aws.String("BucketName"), // Required
  338. }
  339. resp, err := svc.GetBucketCors(params)
  340. if err != nil {
  341. // Print the error, cast err to awserr.Error to get the Code and
  342. // Message from an error.
  343. fmt.Println(err.Error())
  344. return
  345. }
  346. // Pretty-print the response data.
  347. fmt.Println(resp)
  348. }
  349. func ExampleS3_GetBucketLifecycle() {
  350. svc := s3.New(nil)
  351. params := &s3.GetBucketLifecycleInput{
  352. Bucket: aws.String("BucketName"), // Required
  353. }
  354. resp, err := svc.GetBucketLifecycle(params)
  355. if err != nil {
  356. // Print the error, cast err to awserr.Error to get the Code and
  357. // Message from an error.
  358. fmt.Println(err.Error())
  359. return
  360. }
  361. // Pretty-print the response data.
  362. fmt.Println(resp)
  363. }
  364. func ExampleS3_GetBucketLocation() {
  365. svc := s3.New(nil)
  366. params := &s3.GetBucketLocationInput{
  367. Bucket: aws.String("BucketName"), // Required
  368. }
  369. resp, err := svc.GetBucketLocation(params)
  370. if err != nil {
  371. // Print the error, cast err to awserr.Error to get the Code and
  372. // Message from an error.
  373. fmt.Println(err.Error())
  374. return
  375. }
  376. // Pretty-print the response data.
  377. fmt.Println(resp)
  378. }
  379. func ExampleS3_GetBucketLogging() {
  380. svc := s3.New(nil)
  381. params := &s3.GetBucketLoggingInput{
  382. Bucket: aws.String("BucketName"), // Required
  383. }
  384. resp, err := svc.GetBucketLogging(params)
  385. if err != nil {
  386. // Print the error, cast err to awserr.Error to get the Code and
  387. // Message from an error.
  388. fmt.Println(err.Error())
  389. return
  390. }
  391. // Pretty-print the response data.
  392. fmt.Println(resp)
  393. }
  394. func ExampleS3_GetBucketNotification() {
  395. svc := s3.New(nil)
  396. params := &s3.GetBucketNotificationConfigurationRequest{
  397. Bucket: aws.String("BucketName"), // Required
  398. }
  399. resp, err := svc.GetBucketNotification(params)
  400. if err != nil {
  401. // Print the error, cast err to awserr.Error to get the Code and
  402. // Message from an error.
  403. fmt.Println(err.Error())
  404. return
  405. }
  406. // Pretty-print the response data.
  407. fmt.Println(resp)
  408. }
  409. func ExampleS3_GetBucketNotificationConfiguration() {
  410. svc := s3.New(nil)
  411. params := &s3.GetBucketNotificationConfigurationRequest{
  412. Bucket: aws.String("BucketName"), // Required
  413. }
  414. resp, err := svc.GetBucketNotificationConfiguration(params)
  415. if err != nil {
  416. // Print the error, cast err to awserr.Error to get the Code and
  417. // Message from an error.
  418. fmt.Println(err.Error())
  419. return
  420. }
  421. // Pretty-print the response data.
  422. fmt.Println(resp)
  423. }
  424. func ExampleS3_GetBucketPolicy() {
  425. svc := s3.New(nil)
  426. params := &s3.GetBucketPolicyInput{
  427. Bucket: aws.String("BucketName"), // Required
  428. }
  429. resp, err := svc.GetBucketPolicy(params)
  430. if err != nil {
  431. // Print the error, cast err to awserr.Error to get the Code and
  432. // Message from an error.
  433. fmt.Println(err.Error())
  434. return
  435. }
  436. // Pretty-print the response data.
  437. fmt.Println(resp)
  438. }
  439. func ExampleS3_GetBucketReplication() {
  440. svc := s3.New(nil)
  441. params := &s3.GetBucketReplicationInput{
  442. Bucket: aws.String("BucketName"), // Required
  443. }
  444. resp, err := svc.GetBucketReplication(params)
  445. if err != nil {
  446. // Print the error, cast err to awserr.Error to get the Code and
  447. // Message from an error.
  448. fmt.Println(err.Error())
  449. return
  450. }
  451. // Pretty-print the response data.
  452. fmt.Println(resp)
  453. }
  454. func ExampleS3_GetBucketRequestPayment() {
  455. svc := s3.New(nil)
  456. params := &s3.GetBucketRequestPaymentInput{
  457. Bucket: aws.String("BucketName"), // Required
  458. }
  459. resp, err := svc.GetBucketRequestPayment(params)
  460. if err != nil {
  461. // Print the error, cast err to awserr.Error to get the Code and
  462. // Message from an error.
  463. fmt.Println(err.Error())
  464. return
  465. }
  466. // Pretty-print the response data.
  467. fmt.Println(resp)
  468. }
  469. func ExampleS3_GetBucketTagging() {
  470. svc := s3.New(nil)
  471. params := &s3.GetBucketTaggingInput{
  472. Bucket: aws.String("BucketName"), // Required
  473. }
  474. resp, err := svc.GetBucketTagging(params)
  475. if err != nil {
  476. // Print the error, cast err to awserr.Error to get the Code and
  477. // Message from an error.
  478. fmt.Println(err.Error())
  479. return
  480. }
  481. // Pretty-print the response data.
  482. fmt.Println(resp)
  483. }
  484. func ExampleS3_GetBucketVersioning() {
  485. svc := s3.New(nil)
  486. params := &s3.GetBucketVersioningInput{
  487. Bucket: aws.String("BucketName"), // Required
  488. }
  489. resp, err := svc.GetBucketVersioning(params)
  490. if err != nil {
  491. // Print the error, cast err to awserr.Error to get the Code and
  492. // Message from an error.
  493. fmt.Println(err.Error())
  494. return
  495. }
  496. // Pretty-print the response data.
  497. fmt.Println(resp)
  498. }
  499. func ExampleS3_GetBucketWebsite() {
  500. svc := s3.New(nil)
  501. params := &s3.GetBucketWebsiteInput{
  502. Bucket: aws.String("BucketName"), // Required
  503. }
  504. resp, err := svc.GetBucketWebsite(params)
  505. if err != nil {
  506. // Print the error, cast err to awserr.Error to get the Code and
  507. // Message from an error.
  508. fmt.Println(err.Error())
  509. return
  510. }
  511. // Pretty-print the response data.
  512. fmt.Println(resp)
  513. }
  514. func ExampleS3_GetObject() {
  515. svc := s3.New(nil)
  516. params := &s3.GetObjectInput{
  517. Bucket: aws.String("BucketName"), // Required
  518. Key: aws.String("ObjectKey"), // Required
  519. IfMatch: aws.String("IfMatch"),
  520. IfModifiedSince: aws.Time(time.Now()),
  521. IfNoneMatch: aws.String("IfNoneMatch"),
  522. IfUnmodifiedSince: aws.Time(time.Now()),
  523. Range: aws.String("Range"),
  524. RequestPayer: aws.String("RequestPayer"),
  525. ResponseCacheControl: aws.String("ResponseCacheControl"),
  526. ResponseContentDisposition: aws.String("ResponseContentDisposition"),
  527. ResponseContentEncoding: aws.String("ResponseContentEncoding"),
  528. ResponseContentLanguage: aws.String("ResponseContentLanguage"),
  529. ResponseContentType: aws.String("ResponseContentType"),
  530. ResponseExpires: aws.Time(time.Now()),
  531. SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
  532. SSECustomerKey: aws.String("SSECustomerKey"),
  533. SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
  534. VersionId: aws.String("ObjectVersionId"),
  535. }
  536. resp, err := svc.GetObject(params)
  537. if err != nil {
  538. // Print the error, cast err to awserr.Error to get the Code and
  539. // Message from an error.
  540. fmt.Println(err.Error())
  541. return
  542. }
  543. // Pretty-print the response data.
  544. fmt.Println(resp)
  545. }
  546. func ExampleS3_GetObjectAcl() {
  547. svc := s3.New(nil)
  548. params := &s3.GetObjectAclInput{
  549. Bucket: aws.String("BucketName"), // Required
  550. Key: aws.String("ObjectKey"), // Required
  551. RequestPayer: aws.String("RequestPayer"),
  552. VersionId: aws.String("ObjectVersionId"),
  553. }
  554. resp, err := svc.GetObjectAcl(params)
  555. if err != nil {
  556. // Print the error, cast err to awserr.Error to get the Code and
  557. // Message from an error.
  558. fmt.Println(err.Error())
  559. return
  560. }
  561. // Pretty-print the response data.
  562. fmt.Println(resp)
  563. }
  564. func ExampleS3_GetObjectTorrent() {
  565. svc := s3.New(nil)
  566. params := &s3.GetObjectTorrentInput{
  567. Bucket: aws.String("BucketName"), // Required
  568. Key: aws.String("ObjectKey"), // Required
  569. RequestPayer: aws.String("RequestPayer"),
  570. }
  571. resp, err := svc.GetObjectTorrent(params)
  572. if err != nil {
  573. // Print the error, cast err to awserr.Error to get the Code and
  574. // Message from an error.
  575. fmt.Println(err.Error())
  576. return
  577. }
  578. // Pretty-print the response data.
  579. fmt.Println(resp)
  580. }
  581. func ExampleS3_HeadBucket() {
  582. svc := s3.New(nil)
  583. params := &s3.HeadBucketInput{
  584. Bucket: aws.String("BucketName"), // Required
  585. }
  586. resp, err := svc.HeadBucket(params)
  587. if err != nil {
  588. // Print the error, cast err to awserr.Error to get the Code and
  589. // Message from an error.
  590. fmt.Println(err.Error())
  591. return
  592. }
  593. // Pretty-print the response data.
  594. fmt.Println(resp)
  595. }
  596. func ExampleS3_HeadObject() {
  597. svc := s3.New(nil)
  598. params := &s3.HeadObjectInput{
  599. Bucket: aws.String("BucketName"), // Required
  600. Key: aws.String("ObjectKey"), // Required
  601. IfMatch: aws.String("IfMatch"),
  602. IfModifiedSince: aws.Time(time.Now()),
  603. IfNoneMatch: aws.String("IfNoneMatch"),
  604. IfUnmodifiedSince: aws.Time(time.Now()),
  605. Range: aws.String("Range"),
  606. RequestPayer: aws.String("RequestPayer"),
  607. SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
  608. SSECustomerKey: aws.String("SSECustomerKey"),
  609. SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
  610. VersionId: aws.String("ObjectVersionId"),
  611. }
  612. resp, err := svc.HeadObject(params)
  613. if err != nil {
  614. // Print the error, cast err to awserr.Error to get the Code and
  615. // Message from an error.
  616. fmt.Println(err.Error())
  617. return
  618. }
  619. // Pretty-print the response data.
  620. fmt.Println(resp)
  621. }
  622. func ExampleS3_ListBuckets() {
  623. svc := s3.New(nil)
  624. var params *s3.ListBucketsInput
  625. resp, err := svc.ListBuckets(params)
  626. if err != nil {
  627. // Print the error, cast err to awserr.Error to get the Code and
  628. // Message from an error.
  629. fmt.Println(err.Error())
  630. return
  631. }
  632. // Pretty-print the response data.
  633. fmt.Println(resp)
  634. }
  635. func ExampleS3_ListMultipartUploads() {
  636. svc := s3.New(nil)
  637. params := &s3.ListMultipartUploadsInput{
  638. Bucket: aws.String("BucketName"), // Required
  639. Delimiter: aws.String("Delimiter"),
  640. EncodingType: aws.String("EncodingType"),
  641. KeyMarker: aws.String("KeyMarker"),
  642. MaxUploads: aws.Int64(1),
  643. Prefix: aws.String("Prefix"),
  644. UploadIdMarker: aws.String("UploadIdMarker"),
  645. }
  646. resp, err := svc.ListMultipartUploads(params)
  647. if err != nil {
  648. // Print the error, cast err to awserr.Error to get the Code and
  649. // Message from an error.
  650. fmt.Println(err.Error())
  651. return
  652. }
  653. // Pretty-print the response data.
  654. fmt.Println(resp)
  655. }
  656. func ExampleS3_ListObjectVersions() {
  657. svc := s3.New(nil)
  658. params := &s3.ListObjectVersionsInput{
  659. Bucket: aws.String("BucketName"), // Required
  660. Delimiter: aws.String("Delimiter"),
  661. EncodingType: aws.String("EncodingType"),
  662. KeyMarker: aws.String("KeyMarker"),
  663. MaxKeys: aws.Int64(1),
  664. Prefix: aws.String("Prefix"),
  665. VersionIdMarker: aws.String("VersionIdMarker"),
  666. }
  667. resp, err := svc.ListObjectVersions(params)
  668. if err != nil {
  669. // Print the error, cast err to awserr.Error to get the Code and
  670. // Message from an error.
  671. fmt.Println(err.Error())
  672. return
  673. }
  674. // Pretty-print the response data.
  675. fmt.Println(resp)
  676. }
  677. func ExampleS3_ListObjects() {
  678. svc := s3.New(nil)
  679. params := &s3.ListObjectsInput{
  680. Bucket: aws.String("BucketName"), // Required
  681. Delimiter: aws.String("Delimiter"),
  682. EncodingType: aws.String("EncodingType"),
  683. Marker: aws.String("Marker"),
  684. MaxKeys: aws.Int64(1),
  685. Prefix: aws.String("Prefix"),
  686. }
  687. resp, err := svc.ListObjects(params)
  688. if err != nil {
  689. // Print the error, cast err to awserr.Error to get the Code and
  690. // Message from an error.
  691. fmt.Println(err.Error())
  692. return
  693. }
  694. // Pretty-print the response data.
  695. fmt.Println(resp)
  696. }
  697. func ExampleS3_ListParts() {
  698. svc := s3.New(nil)
  699. params := &s3.ListPartsInput{
  700. Bucket: aws.String("BucketName"), // Required
  701. Key: aws.String("ObjectKey"), // Required
  702. UploadId: aws.String("MultipartUploadId"), // Required
  703. MaxParts: aws.Int64(1),
  704. PartNumberMarker: aws.Int64(1),
  705. RequestPayer: aws.String("RequestPayer"),
  706. }
  707. resp, err := svc.ListParts(params)
  708. if err != nil {
  709. // Print the error, cast err to awserr.Error to get the Code and
  710. // Message from an error.
  711. fmt.Println(err.Error())
  712. return
  713. }
  714. // Pretty-print the response data.
  715. fmt.Println(resp)
  716. }
  717. func ExampleS3_PutBucketAcl() {
  718. svc := s3.New(nil)
  719. params := &s3.PutBucketAclInput{
  720. Bucket: aws.String("BucketName"), // Required
  721. ACL: aws.String("BucketCannedACL"),
  722. AccessControlPolicy: &s3.AccessControlPolicy{
  723. Grants: []*s3.Grant{
  724. { // Required
  725. Grantee: &s3.Grantee{
  726. Type: aws.String("Type"), // Required
  727. DisplayName: aws.String("DisplayName"),
  728. EmailAddress: aws.String("EmailAddress"),
  729. ID: aws.String("ID"),
  730. URI: aws.String("URI"),
  731. },
  732. Permission: aws.String("Permission"),
  733. },
  734. // More values...
  735. },
  736. Owner: &s3.Owner{
  737. DisplayName: aws.String("DisplayName"),
  738. ID: aws.String("ID"),
  739. },
  740. },
  741. GrantFullControl: aws.String("GrantFullControl"),
  742. GrantRead: aws.String("GrantRead"),
  743. GrantReadACP: aws.String("GrantReadACP"),
  744. GrantWrite: aws.String("GrantWrite"),
  745. GrantWriteACP: aws.String("GrantWriteACP"),
  746. }
  747. resp, err := svc.PutBucketAcl(params)
  748. if err != nil {
  749. // Print the error, cast err to awserr.Error to get the Code and
  750. // Message from an error.
  751. fmt.Println(err.Error())
  752. return
  753. }
  754. // Pretty-print the response data.
  755. fmt.Println(resp)
  756. }
  757. func ExampleS3_PutBucketCors() {
  758. svc := s3.New(nil)
  759. params := &s3.PutBucketCorsInput{
  760. Bucket: aws.String("BucketName"), // Required
  761. CORSConfiguration: &s3.CORSConfiguration{
  762. CORSRules: []*s3.CORSRule{
  763. { // Required
  764. AllowedHeaders: []*string{
  765. aws.String("AllowedHeader"), // Required
  766. // More values...
  767. },
  768. AllowedMethods: []*string{
  769. aws.String("AllowedMethod"), // Required
  770. // More values...
  771. },
  772. AllowedOrigins: []*string{
  773. aws.String("AllowedOrigin"), // Required
  774. // More values...
  775. },
  776. ExposeHeaders: []*string{
  777. aws.String("ExposeHeader"), // Required
  778. // More values...
  779. },
  780. MaxAgeSeconds: aws.Int64(1),
  781. },
  782. // More values...
  783. },
  784. },
  785. }
  786. resp, err := svc.PutBucketCors(params)
  787. if err != nil {
  788. // Print the error, cast err to awserr.Error to get the Code and
  789. // Message from an error.
  790. fmt.Println(err.Error())
  791. return
  792. }
  793. // Pretty-print the response data.
  794. fmt.Println(resp)
  795. }
  796. func ExampleS3_PutBucketLifecycle() {
  797. svc := s3.New(nil)
  798. params := &s3.PutBucketLifecycleInput{
  799. Bucket: aws.String("BucketName"), // Required
  800. LifecycleConfiguration: &s3.LifecycleConfiguration{
  801. Rules: []*s3.LifecycleRule{ // Required
  802. { // Required
  803. Prefix: aws.String("Prefix"), // Required
  804. Status: aws.String("ExpirationStatus"), // Required
  805. Expiration: &s3.LifecycleExpiration{
  806. Date: aws.Time(time.Now()),
  807. Days: aws.Int64(1),
  808. },
  809. ID: aws.String("ID"),
  810. NoncurrentVersionExpiration: &s3.NoncurrentVersionExpiration{
  811. NoncurrentDays: aws.Int64(1),
  812. },
  813. NoncurrentVersionTransition: &s3.NoncurrentVersionTransition{
  814. NoncurrentDays: aws.Int64(1),
  815. StorageClass: aws.String("TransitionStorageClass"),
  816. },
  817. Transition: &s3.Transition{
  818. Date: aws.Time(time.Now()),
  819. Days: aws.Int64(1),
  820. StorageClass: aws.String("TransitionStorageClass"),
  821. },
  822. },
  823. // More values...
  824. },
  825. },
  826. }
  827. resp, err := svc.PutBucketLifecycle(params)
  828. if err != nil {
  829. // Print the error, cast err to awserr.Error to get the Code and
  830. // Message from an error.
  831. fmt.Println(err.Error())
  832. return
  833. }
  834. // Pretty-print the response data.
  835. fmt.Println(resp)
  836. }
  837. func ExampleS3_PutBucketLogging() {
  838. svc := s3.New(nil)
  839. params := &s3.PutBucketLoggingInput{
  840. Bucket: aws.String("BucketName"), // Required
  841. BucketLoggingStatus: &s3.BucketLoggingStatus{ // Required
  842. LoggingEnabled: &s3.LoggingEnabled{
  843. TargetBucket: aws.String("TargetBucket"),
  844. TargetGrants: []*s3.TargetGrant{
  845. { // Required
  846. Grantee: &s3.Grantee{
  847. Type: aws.String("Type"), // Required
  848. DisplayName: aws.String("DisplayName"),
  849. EmailAddress: aws.String("EmailAddress"),
  850. ID: aws.String("ID"),
  851. URI: aws.String("URI"),
  852. },
  853. Permission: aws.String("BucketLogsPermission"),
  854. },
  855. // More values...
  856. },
  857. TargetPrefix: aws.String("TargetPrefix"),
  858. },
  859. },
  860. }
  861. resp, err := svc.PutBucketLogging(params)
  862. if err != nil {
  863. // Print the error, cast err to awserr.Error to get the Code and
  864. // Message from an error.
  865. fmt.Println(err.Error())
  866. return
  867. }
  868. // Pretty-print the response data.
  869. fmt.Println(resp)
  870. }
  871. func ExampleS3_PutBucketNotification() {
  872. svc := s3.New(nil)
  873. params := &s3.PutBucketNotificationInput{
  874. Bucket: aws.String("BucketName"), // Required
  875. NotificationConfiguration: &s3.NotificationConfigurationDeprecated{ // Required
  876. CloudFunctionConfiguration: &s3.CloudFunctionConfiguration{
  877. CloudFunction: aws.String("CloudFunction"),
  878. Event: aws.String("Event"),
  879. Events: []*string{
  880. aws.String("Event"), // Required
  881. // More values...
  882. },
  883. Id: aws.String("NotificationId"),
  884. InvocationRole: aws.String("CloudFunctionInvocationRole"),
  885. },
  886. QueueConfiguration: &s3.QueueConfigurationDeprecated{
  887. Event: aws.String("Event"),
  888. Events: []*string{
  889. aws.String("Event"), // Required
  890. // More values...
  891. },
  892. Id: aws.String("NotificationId"),
  893. Queue: aws.String("QueueArn"),
  894. },
  895. TopicConfiguration: &s3.TopicConfigurationDeprecated{
  896. Event: aws.String("Event"),
  897. Events: []*string{
  898. aws.String("Event"), // Required
  899. // More values...
  900. },
  901. Id: aws.String("NotificationId"),
  902. Topic: aws.String("TopicArn"),
  903. },
  904. },
  905. }
  906. resp, err := svc.PutBucketNotification(params)
  907. if err != nil {
  908. // Print the error, cast err to awserr.Error to get the Code and
  909. // Message from an error.
  910. fmt.Println(err.Error())
  911. return
  912. }
  913. // Pretty-print the response data.
  914. fmt.Println(resp)
  915. }
  916. func ExampleS3_PutBucketNotificationConfiguration() {
  917. svc := s3.New(nil)
  918. params := &s3.PutBucketNotificationConfigurationInput{
  919. Bucket: aws.String("BucketName"), // Required
  920. NotificationConfiguration: &s3.NotificationConfiguration{ // Required
  921. LambdaFunctionConfigurations: []*s3.LambdaFunctionConfiguration{
  922. { // Required
  923. Events: []*string{ // Required
  924. aws.String("Event"), // Required
  925. // More values...
  926. },
  927. LambdaFunctionArn: aws.String("LambdaFunctionArn"), // Required
  928. Filter: &s3.NotificationConfigurationFilter{
  929. Key: &s3.KeyFilter{
  930. FilterRules: []*s3.FilterRule{
  931. { // Required
  932. Name: aws.String("FilterRuleName"),
  933. Value: aws.String("FilterRuleValue"),
  934. },
  935. // More values...
  936. },
  937. },
  938. },
  939. Id: aws.String("NotificationId"),
  940. },
  941. // More values...
  942. },
  943. QueueConfigurations: []*s3.QueueConfiguration{
  944. { // Required
  945. Events: []*string{ // Required
  946. aws.String("Event"), // Required
  947. // More values...
  948. },
  949. QueueArn: aws.String("QueueArn"), // Required
  950. Filter: &s3.NotificationConfigurationFilter{
  951. Key: &s3.KeyFilter{
  952. FilterRules: []*s3.FilterRule{
  953. { // Required
  954. Name: aws.String("FilterRuleName"),
  955. Value: aws.String("FilterRuleValue"),
  956. },
  957. // More values...
  958. },
  959. },
  960. },
  961. Id: aws.String("NotificationId"),
  962. },
  963. // More values...
  964. },
  965. TopicConfigurations: []*s3.TopicConfiguration{
  966. { // Required
  967. Events: []*string{ // Required
  968. aws.String("Event"), // Required
  969. // More values...
  970. },
  971. TopicArn: aws.String("TopicArn"), // Required
  972. Filter: &s3.NotificationConfigurationFilter{
  973. Key: &s3.KeyFilter{
  974. FilterRules: []*s3.FilterRule{
  975. { // Required
  976. Name: aws.String("FilterRuleName"),
  977. Value: aws.String("FilterRuleValue"),
  978. },
  979. // More values...
  980. },
  981. },
  982. },
  983. Id: aws.String("NotificationId"),
  984. },
  985. // More values...
  986. },
  987. },
  988. }
  989. resp, err := svc.PutBucketNotificationConfiguration(params)
  990. if err != nil {
  991. // Print the error, cast err to awserr.Error to get the Code and
  992. // Message from an error.
  993. fmt.Println(err.Error())
  994. return
  995. }
  996. // Pretty-print the response data.
  997. fmt.Println(resp)
  998. }
  999. func ExampleS3_PutBucketPolicy() {
  1000. svc := s3.New(nil)
  1001. params := &s3.PutBucketPolicyInput{
  1002. Bucket: aws.String("BucketName"), // Required
  1003. Policy: aws.String("Policy"), // Required
  1004. }
  1005. resp, err := svc.PutBucketPolicy(params)
  1006. if err != nil {
  1007. // Print the error, cast err to awserr.Error to get the Code and
  1008. // Message from an error.
  1009. fmt.Println(err.Error())
  1010. return
  1011. }
  1012. // Pretty-print the response data.
  1013. fmt.Println(resp)
  1014. }
  1015. func ExampleS3_PutBucketReplication() {
  1016. svc := s3.New(nil)
  1017. params := &s3.PutBucketReplicationInput{
  1018. Bucket: aws.String("BucketName"), // Required
  1019. ReplicationConfiguration: &s3.ReplicationConfiguration{ // Required
  1020. Role: aws.String("Role"), // Required
  1021. Rules: []*s3.ReplicationRule{ // Required
  1022. { // Required
  1023. Destination: &s3.Destination{ // Required
  1024. Bucket: aws.String("BucketName"), // Required
  1025. },
  1026. Prefix: aws.String("Prefix"), // Required
  1027. Status: aws.String("ReplicationRuleStatus"), // Required
  1028. ID: aws.String("ID"),
  1029. },
  1030. // More values...
  1031. },
  1032. },
  1033. }
  1034. resp, err := svc.PutBucketReplication(params)
  1035. if err != nil {
  1036. // Print the error, cast err to awserr.Error to get the Code and
  1037. // Message from an error.
  1038. fmt.Println(err.Error())
  1039. return
  1040. }
  1041. // Pretty-print the response data.
  1042. fmt.Println(resp)
  1043. }
  1044. func ExampleS3_PutBucketRequestPayment() {
  1045. svc := s3.New(nil)
  1046. params := &s3.PutBucketRequestPaymentInput{
  1047. Bucket: aws.String("BucketName"), // Required
  1048. RequestPaymentConfiguration: &s3.RequestPaymentConfiguration{ // Required
  1049. Payer: aws.String("Payer"), // Required
  1050. },
  1051. }
  1052. resp, err := svc.PutBucketRequestPayment(params)
  1053. if err != nil {
  1054. // Print the error, cast err to awserr.Error to get the Code and
  1055. // Message from an error.
  1056. fmt.Println(err.Error())
  1057. return
  1058. }
  1059. // Pretty-print the response data.
  1060. fmt.Println(resp)
  1061. }
  1062. func ExampleS3_PutBucketTagging() {
  1063. svc := s3.New(nil)
  1064. params := &s3.PutBucketTaggingInput{
  1065. Bucket: aws.String("BucketName"), // Required
  1066. Tagging: &s3.Tagging{ // Required
  1067. TagSet: []*s3.Tag{ // Required
  1068. { // Required
  1069. Key: aws.String("ObjectKey"), // Required
  1070. Value: aws.String("Value"), // Required
  1071. },
  1072. // More values...
  1073. },
  1074. },
  1075. }
  1076. resp, err := svc.PutBucketTagging(params)
  1077. if err != nil {
  1078. // Print the error, cast err to awserr.Error to get the Code and
  1079. // Message from an error.
  1080. fmt.Println(err.Error())
  1081. return
  1082. }
  1083. // Pretty-print the response data.
  1084. fmt.Println(resp)
  1085. }
  1086. func ExampleS3_PutBucketVersioning() {
  1087. svc := s3.New(nil)
  1088. params := &s3.PutBucketVersioningInput{
  1089. Bucket: aws.String("BucketName"), // Required
  1090. VersioningConfiguration: &s3.VersioningConfiguration{ // Required
  1091. MFADelete: aws.String("MFADelete"),
  1092. Status: aws.String("BucketVersioningStatus"),
  1093. },
  1094. MFA: aws.String("MFA"),
  1095. }
  1096. resp, err := svc.PutBucketVersioning(params)
  1097. if err != nil {
  1098. // Print the error, cast err to awserr.Error to get the Code and
  1099. // Message from an error.
  1100. fmt.Println(err.Error())
  1101. return
  1102. }
  1103. // Pretty-print the response data.
  1104. fmt.Println(resp)
  1105. }
  1106. func ExampleS3_PutBucketWebsite() {
  1107. svc := s3.New(nil)
  1108. params := &s3.PutBucketWebsiteInput{
  1109. Bucket: aws.String("BucketName"), // Required
  1110. WebsiteConfiguration: &s3.WebsiteConfiguration{ // Required
  1111. ErrorDocument: &s3.ErrorDocument{
  1112. Key: aws.String("ObjectKey"), // Required
  1113. },
  1114. IndexDocument: &s3.IndexDocument{
  1115. Suffix: aws.String("Suffix"), // Required
  1116. },
  1117. RedirectAllRequestsTo: &s3.RedirectAllRequestsTo{
  1118. HostName: aws.String("HostName"), // Required
  1119. Protocol: aws.String("Protocol"),
  1120. },
  1121. RoutingRules: []*s3.RoutingRule{
  1122. { // Required
  1123. Redirect: &s3.Redirect{ // Required
  1124. HostName: aws.String("HostName"),
  1125. HttpRedirectCode: aws.String("HttpRedirectCode"),
  1126. Protocol: aws.String("Protocol"),
  1127. ReplaceKeyPrefixWith: aws.String("ReplaceKeyPrefixWith"),
  1128. ReplaceKeyWith: aws.String("ReplaceKeyWith"),
  1129. },
  1130. Condition: &s3.Condition{
  1131. HttpErrorCodeReturnedEquals: aws.String("HttpErrorCodeReturnedEquals"),
  1132. KeyPrefixEquals: aws.String("KeyPrefixEquals"),
  1133. },
  1134. },
  1135. // More values...
  1136. },
  1137. },
  1138. }
  1139. resp, err := svc.PutBucketWebsite(params)
  1140. if err != nil {
  1141. // Print the error, cast err to awserr.Error to get the Code and
  1142. // Message from an error.
  1143. fmt.Println(err.Error())
  1144. return
  1145. }
  1146. // Pretty-print the response data.
  1147. fmt.Println(resp)
  1148. }
  1149. func ExampleS3_PutObject() {
  1150. svc := s3.New(nil)
  1151. params := &s3.PutObjectInput{
  1152. Bucket: aws.String("BucketName"), // Required
  1153. Key: aws.String("ObjectKey"), // Required
  1154. ACL: aws.String("ObjectCannedACL"),
  1155. Body: bytes.NewReader([]byte("PAYLOAD")),
  1156. CacheControl: aws.String("CacheControl"),
  1157. ContentDisposition: aws.String("ContentDisposition"),
  1158. ContentEncoding: aws.String("ContentEncoding"),
  1159. ContentLanguage: aws.String("ContentLanguage"),
  1160. ContentLength: aws.Int64(1),
  1161. ContentType: aws.String("ContentType"),
  1162. Expires: aws.Time(time.Now()),
  1163. GrantFullControl: aws.String("GrantFullControl"),
  1164. GrantRead: aws.String("GrantRead"),
  1165. GrantReadACP: aws.String("GrantReadACP"),
  1166. GrantWriteACP: aws.String("GrantWriteACP"),
  1167. Metadata: map[string]*string{
  1168. "Key": aws.String("MetadataValue"), // Required
  1169. // More values...
  1170. },
  1171. RequestPayer: aws.String("RequestPayer"),
  1172. SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
  1173. SSECustomerKey: aws.String("SSECustomerKey"),
  1174. SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
  1175. SSEKMSKeyId: aws.String("SSEKMSKeyId"),
  1176. ServerSideEncryption: aws.String("ServerSideEncryption"),
  1177. StorageClass: aws.String("StorageClass"),
  1178. WebsiteRedirectLocation: aws.String("WebsiteRedirectLocation"),
  1179. }
  1180. resp, err := svc.PutObject(params)
  1181. if err != nil {
  1182. // Print the error, cast err to awserr.Error to get the Code and
  1183. // Message from an error.
  1184. fmt.Println(err.Error())
  1185. return
  1186. }
  1187. // Pretty-print the response data.
  1188. fmt.Println(resp)
  1189. }
  1190. func ExampleS3_PutObjectAcl() {
  1191. svc := s3.New(nil)
  1192. params := &s3.PutObjectAclInput{
  1193. Bucket: aws.String("BucketName"), // Required
  1194. Key: aws.String("ObjectKey"), // Required
  1195. ACL: aws.String("ObjectCannedACL"),
  1196. AccessControlPolicy: &s3.AccessControlPolicy{
  1197. Grants: []*s3.Grant{
  1198. { // Required
  1199. Grantee: &s3.Grantee{
  1200. Type: aws.String("Type"), // Required
  1201. DisplayName: aws.String("DisplayName"),
  1202. EmailAddress: aws.String("EmailAddress"),
  1203. ID: aws.String("ID"),
  1204. URI: aws.String("URI"),
  1205. },
  1206. Permission: aws.String("Permission"),
  1207. },
  1208. // More values...
  1209. },
  1210. Owner: &s3.Owner{
  1211. DisplayName: aws.String("DisplayName"),
  1212. ID: aws.String("ID"),
  1213. },
  1214. },
  1215. GrantFullControl: aws.String("GrantFullControl"),
  1216. GrantRead: aws.String("GrantRead"),
  1217. GrantReadACP: aws.String("GrantReadACP"),
  1218. GrantWrite: aws.String("GrantWrite"),
  1219. GrantWriteACP: aws.String("GrantWriteACP"),
  1220. RequestPayer: aws.String("RequestPayer"),
  1221. }
  1222. resp, err := svc.PutObjectAcl(params)
  1223. if err != nil {
  1224. // Print the error, cast err to awserr.Error to get the Code and
  1225. // Message from an error.
  1226. fmt.Println(err.Error())
  1227. return
  1228. }
  1229. // Pretty-print the response data.
  1230. fmt.Println(resp)
  1231. }
  1232. func ExampleS3_RestoreObject() {
  1233. svc := s3.New(nil)
  1234. params := &s3.RestoreObjectInput{
  1235. Bucket: aws.String("BucketName"), // Required
  1236. Key: aws.String("ObjectKey"), // Required
  1237. RequestPayer: aws.String("RequestPayer"),
  1238. RestoreRequest: &s3.RestoreRequest{
  1239. Days: aws.Int64(1), // Required
  1240. },
  1241. VersionId: aws.String("ObjectVersionId"),
  1242. }
  1243. resp, err := svc.RestoreObject(params)
  1244. if err != nil {
  1245. // Print the error, cast err to awserr.Error to get the Code and
  1246. // Message from an error.
  1247. fmt.Println(err.Error())
  1248. return
  1249. }
  1250. // Pretty-print the response data.
  1251. fmt.Println(resp)
  1252. }
  1253. func ExampleS3_UploadPart() {
  1254. svc := s3.New(nil)
  1255. params := &s3.UploadPartInput{
  1256. Bucket: aws.String("BucketName"), // Required
  1257. Key: aws.String("ObjectKey"), // Required
  1258. PartNumber: aws.Int64(1), // Required
  1259. UploadId: aws.String("MultipartUploadId"), // Required
  1260. Body: bytes.NewReader([]byte("PAYLOAD")),
  1261. ContentLength: aws.Int64(1),
  1262. RequestPayer: aws.String("RequestPayer"),
  1263. SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
  1264. SSECustomerKey: aws.String("SSECustomerKey"),
  1265. SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
  1266. }
  1267. resp, err := svc.UploadPart(params)
  1268. if err != nil {
  1269. // Print the error, cast err to awserr.Error to get the Code and
  1270. // Message from an error.
  1271. fmt.Println(err.Error())
  1272. return
  1273. }
  1274. // Pretty-print the response data.
  1275. fmt.Println(resp)
  1276. }
  1277. func ExampleS3_UploadPartCopy() {
  1278. svc := s3.New(nil)
  1279. params := &s3.UploadPartCopyInput{
  1280. Bucket: aws.String("BucketName"), // Required
  1281. CopySource: aws.String("CopySource"), // Required
  1282. Key: aws.String("ObjectKey"), // Required
  1283. PartNumber: aws.Int64(1), // Required
  1284. UploadId: aws.String("MultipartUploadId"), // Required
  1285. CopySourceIfMatch: aws.String("CopySourceIfMatch"),
  1286. CopySourceIfModifiedSince: aws.Time(time.Now()),
  1287. CopySourceIfNoneMatch: aws.String("CopySourceIfNoneMatch"),
  1288. CopySourceIfUnmodifiedSince: aws.Time(time.Now()),
  1289. CopySourceRange: aws.String("CopySourceRange"),
  1290. CopySourceSSECustomerAlgorithm: aws.String("CopySourceSSECustomerAlgorithm"),
  1291. CopySourceSSECustomerKey: aws.String("CopySourceSSECustomerKey"),
  1292. CopySourceSSECustomerKeyMD5: aws.String("CopySourceSSECustomerKeyMD5"),
  1293. RequestPayer: aws.String("RequestPayer"),
  1294. SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
  1295. SSECustomerKey: aws.String("SSECustomerKey"),
  1296. SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
  1297. }
  1298. resp, err := svc.UploadPartCopy(params)
  1299. if err != nil {
  1300. // Print the error, cast err to awserr.Error to get the Code and
  1301. // Message from an error.
  1302. fmt.Println(err.Error())
  1303. return
  1304. }
  1305. // Pretty-print the response data.
  1306. fmt.Println(resp)
  1307. }