examples_test.go 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029
  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/aws/session"
  9. "github.com/aws/aws-sdk-go/service/s3"
  10. )
  11. var _ time.Duration
  12. var _ bytes.Buffer
  13. func ExampleS3_AbortMultipartUpload() {
  14. sess, err := session.NewSession()
  15. if err != nil {
  16. fmt.Println("failed to create session,", err)
  17. return
  18. }
  19. svc := s3.New(sess)
  20. params := &s3.AbortMultipartUploadInput{
  21. Bucket: aws.String("BucketName"), // Required
  22. Key: aws.String("ObjectKey"), // Required
  23. UploadId: aws.String("MultipartUploadId"), // Required
  24. RequestPayer: aws.String("RequestPayer"),
  25. }
  26. resp, err := svc.AbortMultipartUpload(params)
  27. if err != nil {
  28. // Print the error, cast err to awserr.Error to get the Code and
  29. // Message from an error.
  30. fmt.Println(err.Error())
  31. return
  32. }
  33. // Pretty-print the response data.
  34. fmt.Println(resp)
  35. }
  36. func ExampleS3_CompleteMultipartUpload() {
  37. sess, err := session.NewSession()
  38. if err != nil {
  39. fmt.Println("failed to create session,", err)
  40. return
  41. }
  42. svc := s3.New(sess)
  43. params := &s3.CompleteMultipartUploadInput{
  44. Bucket: aws.String("BucketName"), // Required
  45. Key: aws.String("ObjectKey"), // Required
  46. UploadId: aws.String("MultipartUploadId"), // Required
  47. MultipartUpload: &s3.CompletedMultipartUpload{
  48. Parts: []*s3.CompletedPart{
  49. { // Required
  50. ETag: aws.String("ETag"),
  51. PartNumber: aws.Int64(1),
  52. },
  53. // More values...
  54. },
  55. },
  56. RequestPayer: aws.String("RequestPayer"),
  57. }
  58. resp, err := svc.CompleteMultipartUpload(params)
  59. if err != nil {
  60. // Print the error, cast err to awserr.Error to get the Code and
  61. // Message from an error.
  62. fmt.Println(err.Error())
  63. return
  64. }
  65. // Pretty-print the response data.
  66. fmt.Println(resp)
  67. }
  68. func ExampleS3_CopyObject() {
  69. sess, err := session.NewSession()
  70. if err != nil {
  71. fmt.Println("failed to create session,", err)
  72. return
  73. }
  74. svc := s3.New(sess)
  75. params := &s3.CopyObjectInput{
  76. Bucket: aws.String("BucketName"), // Required
  77. CopySource: aws.String("CopySource"), // Required
  78. Key: aws.String("ObjectKey"), // Required
  79. ACL: aws.String("ObjectCannedACL"),
  80. CacheControl: aws.String("CacheControl"),
  81. ContentDisposition: aws.String("ContentDisposition"),
  82. ContentEncoding: aws.String("ContentEncoding"),
  83. ContentLanguage: aws.String("ContentLanguage"),
  84. ContentType: aws.String("ContentType"),
  85. CopySourceIfMatch: aws.String("CopySourceIfMatch"),
  86. CopySourceIfModifiedSince: aws.Time(time.Now()),
  87. CopySourceIfNoneMatch: aws.String("CopySourceIfNoneMatch"),
  88. CopySourceIfUnmodifiedSince: aws.Time(time.Now()),
  89. CopySourceSSECustomerAlgorithm: aws.String("CopySourceSSECustomerAlgorithm"),
  90. CopySourceSSECustomerKey: aws.String("CopySourceSSECustomerKey"),
  91. CopySourceSSECustomerKeyMD5: aws.String("CopySourceSSECustomerKeyMD5"),
  92. Expires: aws.Time(time.Now()),
  93. GrantFullControl: aws.String("GrantFullControl"),
  94. GrantRead: aws.String("GrantRead"),
  95. GrantReadACP: aws.String("GrantReadACP"),
  96. GrantWriteACP: aws.String("GrantWriteACP"),
  97. Metadata: map[string]*string{
  98. "Key": aws.String("MetadataValue"), // Required
  99. // More values...
  100. },
  101. MetadataDirective: aws.String("MetadataDirective"),
  102. RequestPayer: aws.String("RequestPayer"),
  103. SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
  104. SSECustomerKey: aws.String("SSECustomerKey"),
  105. SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
  106. SSEKMSKeyId: aws.String("SSEKMSKeyId"),
  107. ServerSideEncryption: aws.String("ServerSideEncryption"),
  108. StorageClass: aws.String("StorageClass"),
  109. WebsiteRedirectLocation: aws.String("WebsiteRedirectLocation"),
  110. }
  111. resp, err := svc.CopyObject(params)
  112. if err != nil {
  113. // Print the error, cast err to awserr.Error to get the Code and
  114. // Message from an error.
  115. fmt.Println(err.Error())
  116. return
  117. }
  118. // Pretty-print the response data.
  119. fmt.Println(resp)
  120. }
  121. func ExampleS3_CreateBucket() {
  122. sess, err := session.NewSession()
  123. if err != nil {
  124. fmt.Println("failed to create session,", err)
  125. return
  126. }
  127. svc := s3.New(sess)
  128. params := &s3.CreateBucketInput{
  129. Bucket: aws.String("BucketName"), // Required
  130. ACL: aws.String("BucketCannedACL"),
  131. CreateBucketConfiguration: &s3.CreateBucketConfiguration{
  132. LocationConstraint: aws.String("BucketLocationConstraint"),
  133. },
  134. GrantFullControl: aws.String("GrantFullControl"),
  135. GrantRead: aws.String("GrantRead"),
  136. GrantReadACP: aws.String("GrantReadACP"),
  137. GrantWrite: aws.String("GrantWrite"),
  138. GrantWriteACP: aws.String("GrantWriteACP"),
  139. }
  140. resp, err := svc.CreateBucket(params)
  141. if err != nil {
  142. // Print the error, cast err to awserr.Error to get the Code and
  143. // Message from an error.
  144. fmt.Println(err.Error())
  145. return
  146. }
  147. // Pretty-print the response data.
  148. fmt.Println(resp)
  149. }
  150. func ExampleS3_CreateMultipartUpload() {
  151. sess, err := session.NewSession()
  152. if err != nil {
  153. fmt.Println("failed to create session,", err)
  154. return
  155. }
  156. svc := s3.New(sess)
  157. params := &s3.CreateMultipartUploadInput{
  158. Bucket: aws.String("BucketName"), // Required
  159. Key: aws.String("ObjectKey"), // Required
  160. ACL: aws.String("ObjectCannedACL"),
  161. CacheControl: aws.String("CacheControl"),
  162. ContentDisposition: aws.String("ContentDisposition"),
  163. ContentEncoding: aws.String("ContentEncoding"),
  164. ContentLanguage: aws.String("ContentLanguage"),
  165. ContentType: aws.String("ContentType"),
  166. Expires: aws.Time(time.Now()),
  167. GrantFullControl: aws.String("GrantFullControl"),
  168. GrantRead: aws.String("GrantRead"),
  169. GrantReadACP: aws.String("GrantReadACP"),
  170. GrantWriteACP: aws.String("GrantWriteACP"),
  171. Metadata: map[string]*string{
  172. "Key": aws.String("MetadataValue"), // Required
  173. // More values...
  174. },
  175. RequestPayer: aws.String("RequestPayer"),
  176. SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
  177. SSECustomerKey: aws.String("SSECustomerKey"),
  178. SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
  179. SSEKMSKeyId: aws.String("SSEKMSKeyId"),
  180. ServerSideEncryption: aws.String("ServerSideEncryption"),
  181. StorageClass: aws.String("StorageClass"),
  182. WebsiteRedirectLocation: aws.String("WebsiteRedirectLocation"),
  183. }
  184. resp, err := svc.CreateMultipartUpload(params)
  185. if err != nil {
  186. // Print the error, cast err to awserr.Error to get the Code and
  187. // Message from an error.
  188. fmt.Println(err.Error())
  189. return
  190. }
  191. // Pretty-print the response data.
  192. fmt.Println(resp)
  193. }
  194. func ExampleS3_DeleteBucket() {
  195. sess, err := session.NewSession()
  196. if err != nil {
  197. fmt.Println("failed to create session,", err)
  198. return
  199. }
  200. svc := s3.New(sess)
  201. params := &s3.DeleteBucketInput{
  202. Bucket: aws.String("BucketName"), // Required
  203. }
  204. resp, err := svc.DeleteBucket(params)
  205. if err != nil {
  206. // Print the error, cast err to awserr.Error to get the Code and
  207. // Message from an error.
  208. fmt.Println(err.Error())
  209. return
  210. }
  211. // Pretty-print the response data.
  212. fmt.Println(resp)
  213. }
  214. func ExampleS3_DeleteBucketCors() {
  215. sess, err := session.NewSession()
  216. if err != nil {
  217. fmt.Println("failed to create session,", err)
  218. return
  219. }
  220. svc := s3.New(sess)
  221. params := &s3.DeleteBucketCorsInput{
  222. Bucket: aws.String("BucketName"), // Required
  223. }
  224. resp, err := svc.DeleteBucketCors(params)
  225. if err != nil {
  226. // Print the error, cast err to awserr.Error to get the Code and
  227. // Message from an error.
  228. fmt.Println(err.Error())
  229. return
  230. }
  231. // Pretty-print the response data.
  232. fmt.Println(resp)
  233. }
  234. func ExampleS3_DeleteBucketLifecycle() {
  235. sess, err := session.NewSession()
  236. if err != nil {
  237. fmt.Println("failed to create session,", err)
  238. return
  239. }
  240. svc := s3.New(sess)
  241. params := &s3.DeleteBucketLifecycleInput{
  242. Bucket: aws.String("BucketName"), // Required
  243. }
  244. resp, err := svc.DeleteBucketLifecycle(params)
  245. if err != nil {
  246. // Print the error, cast err to awserr.Error to get the Code and
  247. // Message from an error.
  248. fmt.Println(err.Error())
  249. return
  250. }
  251. // Pretty-print the response data.
  252. fmt.Println(resp)
  253. }
  254. func ExampleS3_DeleteBucketPolicy() {
  255. sess, err := session.NewSession()
  256. if err != nil {
  257. fmt.Println("failed to create session,", err)
  258. return
  259. }
  260. svc := s3.New(sess)
  261. params := &s3.DeleteBucketPolicyInput{
  262. Bucket: aws.String("BucketName"), // Required
  263. }
  264. resp, err := svc.DeleteBucketPolicy(params)
  265. if err != nil {
  266. // Print the error, cast err to awserr.Error to get the Code and
  267. // Message from an error.
  268. fmt.Println(err.Error())
  269. return
  270. }
  271. // Pretty-print the response data.
  272. fmt.Println(resp)
  273. }
  274. func ExampleS3_DeleteBucketReplication() {
  275. sess, err := session.NewSession()
  276. if err != nil {
  277. fmt.Println("failed to create session,", err)
  278. return
  279. }
  280. svc := s3.New(sess)
  281. params := &s3.DeleteBucketReplicationInput{
  282. Bucket: aws.String("BucketName"), // Required
  283. }
  284. resp, err := svc.DeleteBucketReplication(params)
  285. if err != nil {
  286. // Print the error, cast err to awserr.Error to get the Code and
  287. // Message from an error.
  288. fmt.Println(err.Error())
  289. return
  290. }
  291. // Pretty-print the response data.
  292. fmt.Println(resp)
  293. }
  294. func ExampleS3_DeleteBucketTagging() {
  295. sess, err := session.NewSession()
  296. if err != nil {
  297. fmt.Println("failed to create session,", err)
  298. return
  299. }
  300. svc := s3.New(sess)
  301. params := &s3.DeleteBucketTaggingInput{
  302. Bucket: aws.String("BucketName"), // Required
  303. }
  304. resp, err := svc.DeleteBucketTagging(params)
  305. if err != nil {
  306. // Print the error, cast err to awserr.Error to get the Code and
  307. // Message from an error.
  308. fmt.Println(err.Error())
  309. return
  310. }
  311. // Pretty-print the response data.
  312. fmt.Println(resp)
  313. }
  314. func ExampleS3_DeleteBucketWebsite() {
  315. sess, err := session.NewSession()
  316. if err != nil {
  317. fmt.Println("failed to create session,", err)
  318. return
  319. }
  320. svc := s3.New(sess)
  321. params := &s3.DeleteBucketWebsiteInput{
  322. Bucket: aws.String("BucketName"), // Required
  323. }
  324. resp, err := svc.DeleteBucketWebsite(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_DeleteObject() {
  335. sess, err := session.NewSession()
  336. if err != nil {
  337. fmt.Println("failed to create session,", err)
  338. return
  339. }
  340. svc := s3.New(sess)
  341. params := &s3.DeleteObjectInput{
  342. Bucket: aws.String("BucketName"), // Required
  343. Key: aws.String("ObjectKey"), // Required
  344. MFA: aws.String("MFA"),
  345. RequestPayer: aws.String("RequestPayer"),
  346. VersionId: aws.String("ObjectVersionId"),
  347. }
  348. resp, err := svc.DeleteObject(params)
  349. if err != nil {
  350. // Print the error, cast err to awserr.Error to get the Code and
  351. // Message from an error.
  352. fmt.Println(err.Error())
  353. return
  354. }
  355. // Pretty-print the response data.
  356. fmt.Println(resp)
  357. }
  358. func ExampleS3_DeleteObjects() {
  359. sess, err := session.NewSession()
  360. if err != nil {
  361. fmt.Println("failed to create session,", err)
  362. return
  363. }
  364. svc := s3.New(sess)
  365. params := &s3.DeleteObjectsInput{
  366. Bucket: aws.String("BucketName"), // Required
  367. Delete: &s3.Delete{ // Required
  368. Objects: []*s3.ObjectIdentifier{ // Required
  369. { // Required
  370. Key: aws.String("ObjectKey"), // Required
  371. VersionId: aws.String("ObjectVersionId"),
  372. },
  373. // More values...
  374. },
  375. Quiet: aws.Bool(true),
  376. },
  377. MFA: aws.String("MFA"),
  378. RequestPayer: aws.String("RequestPayer"),
  379. }
  380. resp, err := svc.DeleteObjects(params)
  381. if err != nil {
  382. // Print the error, cast err to awserr.Error to get the Code and
  383. // Message from an error.
  384. fmt.Println(err.Error())
  385. return
  386. }
  387. // Pretty-print the response data.
  388. fmt.Println(resp)
  389. }
  390. func ExampleS3_GetBucketAccelerateConfiguration() {
  391. sess, err := session.NewSession()
  392. if err != nil {
  393. fmt.Println("failed to create session,", err)
  394. return
  395. }
  396. svc := s3.New(sess)
  397. params := &s3.GetBucketAccelerateConfigurationInput{
  398. Bucket: aws.String("BucketName"), // Required
  399. }
  400. resp, err := svc.GetBucketAccelerateConfiguration(params)
  401. if err != nil {
  402. // Print the error, cast err to awserr.Error to get the Code and
  403. // Message from an error.
  404. fmt.Println(err.Error())
  405. return
  406. }
  407. // Pretty-print the response data.
  408. fmt.Println(resp)
  409. }
  410. func ExampleS3_GetBucketAcl() {
  411. sess, err := session.NewSession()
  412. if err != nil {
  413. fmt.Println("failed to create session,", err)
  414. return
  415. }
  416. svc := s3.New(sess)
  417. params := &s3.GetBucketAclInput{
  418. Bucket: aws.String("BucketName"), // Required
  419. }
  420. resp, err := svc.GetBucketAcl(params)
  421. if err != nil {
  422. // Print the error, cast err to awserr.Error to get the Code and
  423. // Message from an error.
  424. fmt.Println(err.Error())
  425. return
  426. }
  427. // Pretty-print the response data.
  428. fmt.Println(resp)
  429. }
  430. func ExampleS3_GetBucketCors() {
  431. sess, err := session.NewSession()
  432. if err != nil {
  433. fmt.Println("failed to create session,", err)
  434. return
  435. }
  436. svc := s3.New(sess)
  437. params := &s3.GetBucketCorsInput{
  438. Bucket: aws.String("BucketName"), // Required
  439. }
  440. resp, err := svc.GetBucketCors(params)
  441. if err != nil {
  442. // Print the error, cast err to awserr.Error to get the Code and
  443. // Message from an error.
  444. fmt.Println(err.Error())
  445. return
  446. }
  447. // Pretty-print the response data.
  448. fmt.Println(resp)
  449. }
  450. func ExampleS3_GetBucketLifecycle() {
  451. sess, err := session.NewSession()
  452. if err != nil {
  453. fmt.Println("failed to create session,", err)
  454. return
  455. }
  456. svc := s3.New(sess)
  457. params := &s3.GetBucketLifecycleInput{
  458. Bucket: aws.String("BucketName"), // Required
  459. }
  460. resp, err := svc.GetBucketLifecycle(params)
  461. if err != nil {
  462. // Print the error, cast err to awserr.Error to get the Code and
  463. // Message from an error.
  464. fmt.Println(err.Error())
  465. return
  466. }
  467. // Pretty-print the response data.
  468. fmt.Println(resp)
  469. }
  470. func ExampleS3_GetBucketLifecycleConfiguration() {
  471. sess, err := session.NewSession()
  472. if err != nil {
  473. fmt.Println("failed to create session,", err)
  474. return
  475. }
  476. svc := s3.New(sess)
  477. params := &s3.GetBucketLifecycleConfigurationInput{
  478. Bucket: aws.String("BucketName"), // Required
  479. }
  480. resp, err := svc.GetBucketLifecycleConfiguration(params)
  481. if err != nil {
  482. // Print the error, cast err to awserr.Error to get the Code and
  483. // Message from an error.
  484. fmt.Println(err.Error())
  485. return
  486. }
  487. // Pretty-print the response data.
  488. fmt.Println(resp)
  489. }
  490. func ExampleS3_GetBucketLocation() {
  491. sess, err := session.NewSession()
  492. if err != nil {
  493. fmt.Println("failed to create session,", err)
  494. return
  495. }
  496. svc := s3.New(sess)
  497. params := &s3.GetBucketLocationInput{
  498. Bucket: aws.String("BucketName"), // Required
  499. }
  500. resp, err := svc.GetBucketLocation(params)
  501. if err != nil {
  502. // Print the error, cast err to awserr.Error to get the Code and
  503. // Message from an error.
  504. fmt.Println(err.Error())
  505. return
  506. }
  507. // Pretty-print the response data.
  508. fmt.Println(resp)
  509. }
  510. func ExampleS3_GetBucketLogging() {
  511. sess, err := session.NewSession()
  512. if err != nil {
  513. fmt.Println("failed to create session,", err)
  514. return
  515. }
  516. svc := s3.New(sess)
  517. params := &s3.GetBucketLoggingInput{
  518. Bucket: aws.String("BucketName"), // Required
  519. }
  520. resp, err := svc.GetBucketLogging(params)
  521. if err != nil {
  522. // Print the error, cast err to awserr.Error to get the Code and
  523. // Message from an error.
  524. fmt.Println(err.Error())
  525. return
  526. }
  527. // Pretty-print the response data.
  528. fmt.Println(resp)
  529. }
  530. func ExampleS3_GetBucketNotification() {
  531. sess, err := session.NewSession()
  532. if err != nil {
  533. fmt.Println("failed to create session,", err)
  534. return
  535. }
  536. svc := s3.New(sess)
  537. params := &s3.GetBucketNotificationConfigurationRequest{
  538. Bucket: aws.String("BucketName"), // Required
  539. }
  540. resp, err := svc.GetBucketNotification(params)
  541. if err != nil {
  542. // Print the error, cast err to awserr.Error to get the Code and
  543. // Message from an error.
  544. fmt.Println(err.Error())
  545. return
  546. }
  547. // Pretty-print the response data.
  548. fmt.Println(resp)
  549. }
  550. func ExampleS3_GetBucketNotificationConfiguration() {
  551. sess, err := session.NewSession()
  552. if err != nil {
  553. fmt.Println("failed to create session,", err)
  554. return
  555. }
  556. svc := s3.New(sess)
  557. params := &s3.GetBucketNotificationConfigurationRequest{
  558. Bucket: aws.String("BucketName"), // Required
  559. }
  560. resp, err := svc.GetBucketNotificationConfiguration(params)
  561. if err != nil {
  562. // Print the error, cast err to awserr.Error to get the Code and
  563. // Message from an error.
  564. fmt.Println(err.Error())
  565. return
  566. }
  567. // Pretty-print the response data.
  568. fmt.Println(resp)
  569. }
  570. func ExampleS3_GetBucketPolicy() {
  571. sess, err := session.NewSession()
  572. if err != nil {
  573. fmt.Println("failed to create session,", err)
  574. return
  575. }
  576. svc := s3.New(sess)
  577. params := &s3.GetBucketPolicyInput{
  578. Bucket: aws.String("BucketName"), // Required
  579. }
  580. resp, err := svc.GetBucketPolicy(params)
  581. if err != nil {
  582. // Print the error, cast err to awserr.Error to get the Code and
  583. // Message from an error.
  584. fmt.Println(err.Error())
  585. return
  586. }
  587. // Pretty-print the response data.
  588. fmt.Println(resp)
  589. }
  590. func ExampleS3_GetBucketReplication() {
  591. sess, err := session.NewSession()
  592. if err != nil {
  593. fmt.Println("failed to create session,", err)
  594. return
  595. }
  596. svc := s3.New(sess)
  597. params := &s3.GetBucketReplicationInput{
  598. Bucket: aws.String("BucketName"), // Required
  599. }
  600. resp, err := svc.GetBucketReplication(params)
  601. if err != nil {
  602. // Print the error, cast err to awserr.Error to get the Code and
  603. // Message from an error.
  604. fmt.Println(err.Error())
  605. return
  606. }
  607. // Pretty-print the response data.
  608. fmt.Println(resp)
  609. }
  610. func ExampleS3_GetBucketRequestPayment() {
  611. sess, err := session.NewSession()
  612. if err != nil {
  613. fmt.Println("failed to create session,", err)
  614. return
  615. }
  616. svc := s3.New(sess)
  617. params := &s3.GetBucketRequestPaymentInput{
  618. Bucket: aws.String("BucketName"), // Required
  619. }
  620. resp, err := svc.GetBucketRequestPayment(params)
  621. if err != nil {
  622. // Print the error, cast err to awserr.Error to get the Code and
  623. // Message from an error.
  624. fmt.Println(err.Error())
  625. return
  626. }
  627. // Pretty-print the response data.
  628. fmt.Println(resp)
  629. }
  630. func ExampleS3_GetBucketTagging() {
  631. sess, err := session.NewSession()
  632. if err != nil {
  633. fmt.Println("failed to create session,", err)
  634. return
  635. }
  636. svc := s3.New(sess)
  637. params := &s3.GetBucketTaggingInput{
  638. Bucket: aws.String("BucketName"), // Required
  639. }
  640. resp, err := svc.GetBucketTagging(params)
  641. if err != nil {
  642. // Print the error, cast err to awserr.Error to get the Code and
  643. // Message from an error.
  644. fmt.Println(err.Error())
  645. return
  646. }
  647. // Pretty-print the response data.
  648. fmt.Println(resp)
  649. }
  650. func ExampleS3_GetBucketVersioning() {
  651. sess, err := session.NewSession()
  652. if err != nil {
  653. fmt.Println("failed to create session,", err)
  654. return
  655. }
  656. svc := s3.New(sess)
  657. params := &s3.GetBucketVersioningInput{
  658. Bucket: aws.String("BucketName"), // Required
  659. }
  660. resp, err := svc.GetBucketVersioning(params)
  661. if err != nil {
  662. // Print the error, cast err to awserr.Error to get the Code and
  663. // Message from an error.
  664. fmt.Println(err.Error())
  665. return
  666. }
  667. // Pretty-print the response data.
  668. fmt.Println(resp)
  669. }
  670. func ExampleS3_GetBucketWebsite() {
  671. sess, err := session.NewSession()
  672. if err != nil {
  673. fmt.Println("failed to create session,", err)
  674. return
  675. }
  676. svc := s3.New(sess)
  677. params := &s3.GetBucketWebsiteInput{
  678. Bucket: aws.String("BucketName"), // Required
  679. }
  680. resp, err := svc.GetBucketWebsite(params)
  681. if err != nil {
  682. // Print the error, cast err to awserr.Error to get the Code and
  683. // Message from an error.
  684. fmt.Println(err.Error())
  685. return
  686. }
  687. // Pretty-print the response data.
  688. fmt.Println(resp)
  689. }
  690. func ExampleS3_GetObject() {
  691. sess, err := session.NewSession()
  692. if err != nil {
  693. fmt.Println("failed to create session,", err)
  694. return
  695. }
  696. svc := s3.New(sess)
  697. params := &s3.GetObjectInput{
  698. Bucket: aws.String("BucketName"), // Required
  699. Key: aws.String("ObjectKey"), // Required
  700. IfMatch: aws.String("IfMatch"),
  701. IfModifiedSince: aws.Time(time.Now()),
  702. IfNoneMatch: aws.String("IfNoneMatch"),
  703. IfUnmodifiedSince: aws.Time(time.Now()),
  704. Range: aws.String("Range"),
  705. RequestPayer: aws.String("RequestPayer"),
  706. ResponseCacheControl: aws.String("ResponseCacheControl"),
  707. ResponseContentDisposition: aws.String("ResponseContentDisposition"),
  708. ResponseContentEncoding: aws.String("ResponseContentEncoding"),
  709. ResponseContentLanguage: aws.String("ResponseContentLanguage"),
  710. ResponseContentType: aws.String("ResponseContentType"),
  711. ResponseExpires: aws.Time(time.Now()),
  712. SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
  713. SSECustomerKey: aws.String("SSECustomerKey"),
  714. SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
  715. VersionId: aws.String("ObjectVersionId"),
  716. }
  717. resp, err := svc.GetObject(params)
  718. if err != nil {
  719. // Print the error, cast err to awserr.Error to get the Code and
  720. // Message from an error.
  721. fmt.Println(err.Error())
  722. return
  723. }
  724. // Pretty-print the response data.
  725. fmt.Println(resp)
  726. }
  727. func ExampleS3_GetObjectAcl() {
  728. sess, err := session.NewSession()
  729. if err != nil {
  730. fmt.Println("failed to create session,", err)
  731. return
  732. }
  733. svc := s3.New(sess)
  734. params := &s3.GetObjectAclInput{
  735. Bucket: aws.String("BucketName"), // Required
  736. Key: aws.String("ObjectKey"), // Required
  737. RequestPayer: aws.String("RequestPayer"),
  738. VersionId: aws.String("ObjectVersionId"),
  739. }
  740. resp, err := svc.GetObjectAcl(params)
  741. if err != nil {
  742. // Print the error, cast err to awserr.Error to get the Code and
  743. // Message from an error.
  744. fmt.Println(err.Error())
  745. return
  746. }
  747. // Pretty-print the response data.
  748. fmt.Println(resp)
  749. }
  750. func ExampleS3_GetObjectTorrent() {
  751. sess, err := session.NewSession()
  752. if err != nil {
  753. fmt.Println("failed to create session,", err)
  754. return
  755. }
  756. svc := s3.New(sess)
  757. params := &s3.GetObjectTorrentInput{
  758. Bucket: aws.String("BucketName"), // Required
  759. Key: aws.String("ObjectKey"), // Required
  760. RequestPayer: aws.String("RequestPayer"),
  761. }
  762. resp, err := svc.GetObjectTorrent(params)
  763. if err != nil {
  764. // Print the error, cast err to awserr.Error to get the Code and
  765. // Message from an error.
  766. fmt.Println(err.Error())
  767. return
  768. }
  769. // Pretty-print the response data.
  770. fmt.Println(resp)
  771. }
  772. func ExampleS3_HeadBucket() {
  773. sess, err := session.NewSession()
  774. if err != nil {
  775. fmt.Println("failed to create session,", err)
  776. return
  777. }
  778. svc := s3.New(sess)
  779. params := &s3.HeadBucketInput{
  780. Bucket: aws.String("BucketName"), // Required
  781. }
  782. resp, err := svc.HeadBucket(params)
  783. if err != nil {
  784. // Print the error, cast err to awserr.Error to get the Code and
  785. // Message from an error.
  786. fmt.Println(err.Error())
  787. return
  788. }
  789. // Pretty-print the response data.
  790. fmt.Println(resp)
  791. }
  792. func ExampleS3_HeadObject() {
  793. sess, err := session.NewSession()
  794. if err != nil {
  795. fmt.Println("failed to create session,", err)
  796. return
  797. }
  798. svc := s3.New(sess)
  799. params := &s3.HeadObjectInput{
  800. Bucket: aws.String("BucketName"), // Required
  801. Key: aws.String("ObjectKey"), // Required
  802. IfMatch: aws.String("IfMatch"),
  803. IfModifiedSince: aws.Time(time.Now()),
  804. IfNoneMatch: aws.String("IfNoneMatch"),
  805. IfUnmodifiedSince: aws.Time(time.Now()),
  806. Range: aws.String("Range"),
  807. RequestPayer: aws.String("RequestPayer"),
  808. SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
  809. SSECustomerKey: aws.String("SSECustomerKey"),
  810. SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
  811. VersionId: aws.String("ObjectVersionId"),
  812. }
  813. resp, err := svc.HeadObject(params)
  814. if err != nil {
  815. // Print the error, cast err to awserr.Error to get the Code and
  816. // Message from an error.
  817. fmt.Println(err.Error())
  818. return
  819. }
  820. // Pretty-print the response data.
  821. fmt.Println(resp)
  822. }
  823. func ExampleS3_ListBuckets() {
  824. sess, err := session.NewSession()
  825. if err != nil {
  826. fmt.Println("failed to create session,", err)
  827. return
  828. }
  829. svc := s3.New(sess)
  830. var params *s3.ListBucketsInput
  831. resp, err := svc.ListBuckets(params)
  832. if err != nil {
  833. // Print the error, cast err to awserr.Error to get the Code and
  834. // Message from an error.
  835. fmt.Println(err.Error())
  836. return
  837. }
  838. // Pretty-print the response data.
  839. fmt.Println(resp)
  840. }
  841. func ExampleS3_ListMultipartUploads() {
  842. sess, err := session.NewSession()
  843. if err != nil {
  844. fmt.Println("failed to create session,", err)
  845. return
  846. }
  847. svc := s3.New(sess)
  848. params := &s3.ListMultipartUploadsInput{
  849. Bucket: aws.String("BucketName"), // Required
  850. Delimiter: aws.String("Delimiter"),
  851. EncodingType: aws.String("EncodingType"),
  852. KeyMarker: aws.String("KeyMarker"),
  853. MaxUploads: aws.Int64(1),
  854. Prefix: aws.String("Prefix"),
  855. UploadIdMarker: aws.String("UploadIdMarker"),
  856. }
  857. resp, err := svc.ListMultipartUploads(params)
  858. if err != nil {
  859. // Print the error, cast err to awserr.Error to get the Code and
  860. // Message from an error.
  861. fmt.Println(err.Error())
  862. return
  863. }
  864. // Pretty-print the response data.
  865. fmt.Println(resp)
  866. }
  867. func ExampleS3_ListObjectVersions() {
  868. sess, err := session.NewSession()
  869. if err != nil {
  870. fmt.Println("failed to create session,", err)
  871. return
  872. }
  873. svc := s3.New(sess)
  874. params := &s3.ListObjectVersionsInput{
  875. Bucket: aws.String("BucketName"), // Required
  876. Delimiter: aws.String("Delimiter"),
  877. EncodingType: aws.String("EncodingType"),
  878. KeyMarker: aws.String("KeyMarker"),
  879. MaxKeys: aws.Int64(1),
  880. Prefix: aws.String("Prefix"),
  881. VersionIdMarker: aws.String("VersionIdMarker"),
  882. }
  883. resp, err := svc.ListObjectVersions(params)
  884. if err != nil {
  885. // Print the error, cast err to awserr.Error to get the Code and
  886. // Message from an error.
  887. fmt.Println(err.Error())
  888. return
  889. }
  890. // Pretty-print the response data.
  891. fmt.Println(resp)
  892. }
  893. func ExampleS3_ListObjects() {
  894. sess, err := session.NewSession()
  895. if err != nil {
  896. fmt.Println("failed to create session,", err)
  897. return
  898. }
  899. svc := s3.New(sess)
  900. params := &s3.ListObjectsInput{
  901. Bucket: aws.String("BucketName"), // Required
  902. Delimiter: aws.String("Delimiter"),
  903. EncodingType: aws.String("EncodingType"),
  904. Marker: aws.String("Marker"),
  905. MaxKeys: aws.Int64(1),
  906. Prefix: aws.String("Prefix"),
  907. }
  908. resp, err := svc.ListObjects(params)
  909. if err != nil {
  910. // Print the error, cast err to awserr.Error to get the Code and
  911. // Message from an error.
  912. fmt.Println(err.Error())
  913. return
  914. }
  915. // Pretty-print the response data.
  916. fmt.Println(resp)
  917. }
  918. func ExampleS3_ListObjectsV2() {
  919. sess, err := session.NewSession()
  920. if err != nil {
  921. fmt.Println("failed to create session,", err)
  922. return
  923. }
  924. svc := s3.New(sess)
  925. params := &s3.ListObjectsV2Input{
  926. Bucket: aws.String("BucketName"), // Required
  927. ContinuationToken: aws.String("Token"),
  928. Delimiter: aws.String("Delimiter"),
  929. EncodingType: aws.String("EncodingType"),
  930. FetchOwner: aws.Bool(true),
  931. MaxKeys: aws.Int64(1),
  932. Prefix: aws.String("Prefix"),
  933. StartAfter: aws.String("StartAfter"),
  934. }
  935. resp, err := svc.ListObjectsV2(params)
  936. if err != nil {
  937. // Print the error, cast err to awserr.Error to get the Code and
  938. // Message from an error.
  939. fmt.Println(err.Error())
  940. return
  941. }
  942. // Pretty-print the response data.
  943. fmt.Println(resp)
  944. }
  945. func ExampleS3_ListParts() {
  946. sess, err := session.NewSession()
  947. if err != nil {
  948. fmt.Println("failed to create session,", err)
  949. return
  950. }
  951. svc := s3.New(sess)
  952. params := &s3.ListPartsInput{
  953. Bucket: aws.String("BucketName"), // Required
  954. Key: aws.String("ObjectKey"), // Required
  955. UploadId: aws.String("MultipartUploadId"), // Required
  956. MaxParts: aws.Int64(1),
  957. PartNumberMarker: aws.Int64(1),
  958. RequestPayer: aws.String("RequestPayer"),
  959. }
  960. resp, err := svc.ListParts(params)
  961. if err != nil {
  962. // Print the error, cast err to awserr.Error to get the Code and
  963. // Message from an error.
  964. fmt.Println(err.Error())
  965. return
  966. }
  967. // Pretty-print the response data.
  968. fmt.Println(resp)
  969. }
  970. func ExampleS3_PutBucketAccelerateConfiguration() {
  971. sess, err := session.NewSession()
  972. if err != nil {
  973. fmt.Println("failed to create session,", err)
  974. return
  975. }
  976. svc := s3.New(sess)
  977. params := &s3.PutBucketAccelerateConfigurationInput{
  978. AccelerateConfiguration: &s3.AccelerateConfiguration{ // Required
  979. Status: aws.String("BucketAccelerateStatus"),
  980. },
  981. Bucket: aws.String("BucketName"), // Required
  982. }
  983. resp, err := svc.PutBucketAccelerateConfiguration(params)
  984. if err != nil {
  985. // Print the error, cast err to awserr.Error to get the Code and
  986. // Message from an error.
  987. fmt.Println(err.Error())
  988. return
  989. }
  990. // Pretty-print the response data.
  991. fmt.Println(resp)
  992. }
  993. func ExampleS3_PutBucketAcl() {
  994. sess, err := session.NewSession()
  995. if err != nil {
  996. fmt.Println("failed to create session,", err)
  997. return
  998. }
  999. svc := s3.New(sess)
  1000. params := &s3.PutBucketAclInput{
  1001. Bucket: aws.String("BucketName"), // Required
  1002. ACL: aws.String("BucketCannedACL"),
  1003. AccessControlPolicy: &s3.AccessControlPolicy{
  1004. Grants: []*s3.Grant{
  1005. { // Required
  1006. Grantee: &s3.Grantee{
  1007. Type: aws.String("Type"), // Required
  1008. DisplayName: aws.String("DisplayName"),
  1009. EmailAddress: aws.String("EmailAddress"),
  1010. ID: aws.String("ID"),
  1011. URI: aws.String("URI"),
  1012. },
  1013. Permission: aws.String("Permission"),
  1014. },
  1015. // More values...
  1016. },
  1017. Owner: &s3.Owner{
  1018. DisplayName: aws.String("DisplayName"),
  1019. ID: aws.String("ID"),
  1020. },
  1021. },
  1022. GrantFullControl: aws.String("GrantFullControl"),
  1023. GrantRead: aws.String("GrantRead"),
  1024. GrantReadACP: aws.String("GrantReadACP"),
  1025. GrantWrite: aws.String("GrantWrite"),
  1026. GrantWriteACP: aws.String("GrantWriteACP"),
  1027. }
  1028. resp, err := svc.PutBucketAcl(params)
  1029. if err != nil {
  1030. // Print the error, cast err to awserr.Error to get the Code and
  1031. // Message from an error.
  1032. fmt.Println(err.Error())
  1033. return
  1034. }
  1035. // Pretty-print the response data.
  1036. fmt.Println(resp)
  1037. }
  1038. func ExampleS3_PutBucketCors() {
  1039. sess, err := session.NewSession()
  1040. if err != nil {
  1041. fmt.Println("failed to create session,", err)
  1042. return
  1043. }
  1044. svc := s3.New(sess)
  1045. params := &s3.PutBucketCorsInput{
  1046. Bucket: aws.String("BucketName"), // Required
  1047. CORSConfiguration: &s3.CORSConfiguration{ // Required
  1048. CORSRules: []*s3.CORSRule{ // Required
  1049. { // Required
  1050. AllowedMethods: []*string{ // Required
  1051. aws.String("AllowedMethod"), // Required
  1052. // More values...
  1053. },
  1054. AllowedOrigins: []*string{ // Required
  1055. aws.String("AllowedOrigin"), // Required
  1056. // More values...
  1057. },
  1058. AllowedHeaders: []*string{
  1059. aws.String("AllowedHeader"), // Required
  1060. // More values...
  1061. },
  1062. ExposeHeaders: []*string{
  1063. aws.String("ExposeHeader"), // Required
  1064. // More values...
  1065. },
  1066. MaxAgeSeconds: aws.Int64(1),
  1067. },
  1068. // More values...
  1069. },
  1070. },
  1071. }
  1072. resp, err := svc.PutBucketCors(params)
  1073. if err != nil {
  1074. // Print the error, cast err to awserr.Error to get the Code and
  1075. // Message from an error.
  1076. fmt.Println(err.Error())
  1077. return
  1078. }
  1079. // Pretty-print the response data.
  1080. fmt.Println(resp)
  1081. }
  1082. func ExampleS3_PutBucketLifecycle() {
  1083. sess, err := session.NewSession()
  1084. if err != nil {
  1085. fmt.Println("failed to create session,", err)
  1086. return
  1087. }
  1088. svc := s3.New(sess)
  1089. params := &s3.PutBucketLifecycleInput{
  1090. Bucket: aws.String("BucketName"), // Required
  1091. LifecycleConfiguration: &s3.LifecycleConfiguration{
  1092. Rules: []*s3.Rule{ // Required
  1093. { // Required
  1094. Prefix: aws.String("Prefix"), // Required
  1095. Status: aws.String("ExpirationStatus"), // Required
  1096. AbortIncompleteMultipartUpload: &s3.AbortIncompleteMultipartUpload{
  1097. DaysAfterInitiation: aws.Int64(1),
  1098. },
  1099. Expiration: &s3.LifecycleExpiration{
  1100. Date: aws.Time(time.Now()),
  1101. Days: aws.Int64(1),
  1102. ExpiredObjectDeleteMarker: aws.Bool(true),
  1103. },
  1104. ID: aws.String("ID"),
  1105. NoncurrentVersionExpiration: &s3.NoncurrentVersionExpiration{
  1106. NoncurrentDays: aws.Int64(1),
  1107. },
  1108. NoncurrentVersionTransition: &s3.NoncurrentVersionTransition{
  1109. NoncurrentDays: aws.Int64(1),
  1110. StorageClass: aws.String("TransitionStorageClass"),
  1111. },
  1112. Transition: &s3.Transition{
  1113. Date: aws.Time(time.Now()),
  1114. Days: aws.Int64(1),
  1115. StorageClass: aws.String("TransitionStorageClass"),
  1116. },
  1117. },
  1118. // More values...
  1119. },
  1120. },
  1121. }
  1122. resp, err := svc.PutBucketLifecycle(params)
  1123. if err != nil {
  1124. // Print the error, cast err to awserr.Error to get the Code and
  1125. // Message from an error.
  1126. fmt.Println(err.Error())
  1127. return
  1128. }
  1129. // Pretty-print the response data.
  1130. fmt.Println(resp)
  1131. }
  1132. func ExampleS3_PutBucketLifecycleConfiguration() {
  1133. sess, err := session.NewSession()
  1134. if err != nil {
  1135. fmt.Println("failed to create session,", err)
  1136. return
  1137. }
  1138. svc := s3.New(sess)
  1139. params := &s3.PutBucketLifecycleConfigurationInput{
  1140. Bucket: aws.String("BucketName"), // Required
  1141. LifecycleConfiguration: &s3.BucketLifecycleConfiguration{
  1142. Rules: []*s3.LifecycleRule{ // Required
  1143. { // Required
  1144. Prefix: aws.String("Prefix"), // Required
  1145. Status: aws.String("ExpirationStatus"), // Required
  1146. AbortIncompleteMultipartUpload: &s3.AbortIncompleteMultipartUpload{
  1147. DaysAfterInitiation: aws.Int64(1),
  1148. },
  1149. Expiration: &s3.LifecycleExpiration{
  1150. Date: aws.Time(time.Now()),
  1151. Days: aws.Int64(1),
  1152. ExpiredObjectDeleteMarker: aws.Bool(true),
  1153. },
  1154. ID: aws.String("ID"),
  1155. NoncurrentVersionExpiration: &s3.NoncurrentVersionExpiration{
  1156. NoncurrentDays: aws.Int64(1),
  1157. },
  1158. NoncurrentVersionTransitions: []*s3.NoncurrentVersionTransition{
  1159. { // Required
  1160. NoncurrentDays: aws.Int64(1),
  1161. StorageClass: aws.String("TransitionStorageClass"),
  1162. },
  1163. // More values...
  1164. },
  1165. Transitions: []*s3.Transition{
  1166. { // Required
  1167. Date: aws.Time(time.Now()),
  1168. Days: aws.Int64(1),
  1169. StorageClass: aws.String("TransitionStorageClass"),
  1170. },
  1171. // More values...
  1172. },
  1173. },
  1174. // More values...
  1175. },
  1176. },
  1177. }
  1178. resp, err := svc.PutBucketLifecycleConfiguration(params)
  1179. if err != nil {
  1180. // Print the error, cast err to awserr.Error to get the Code and
  1181. // Message from an error.
  1182. fmt.Println(err.Error())
  1183. return
  1184. }
  1185. // Pretty-print the response data.
  1186. fmt.Println(resp)
  1187. }
  1188. func ExampleS3_PutBucketLogging() {
  1189. sess, err := session.NewSession()
  1190. if err != nil {
  1191. fmt.Println("failed to create session,", err)
  1192. return
  1193. }
  1194. svc := s3.New(sess)
  1195. params := &s3.PutBucketLoggingInput{
  1196. Bucket: aws.String("BucketName"), // Required
  1197. BucketLoggingStatus: &s3.BucketLoggingStatus{ // Required
  1198. LoggingEnabled: &s3.LoggingEnabled{
  1199. TargetBucket: aws.String("TargetBucket"),
  1200. TargetGrants: []*s3.TargetGrant{
  1201. { // Required
  1202. Grantee: &s3.Grantee{
  1203. Type: aws.String("Type"), // Required
  1204. DisplayName: aws.String("DisplayName"),
  1205. EmailAddress: aws.String("EmailAddress"),
  1206. ID: aws.String("ID"),
  1207. URI: aws.String("URI"),
  1208. },
  1209. Permission: aws.String("BucketLogsPermission"),
  1210. },
  1211. // More values...
  1212. },
  1213. TargetPrefix: aws.String("TargetPrefix"),
  1214. },
  1215. },
  1216. }
  1217. resp, err := svc.PutBucketLogging(params)
  1218. if err != nil {
  1219. // Print the error, cast err to awserr.Error to get the Code and
  1220. // Message from an error.
  1221. fmt.Println(err.Error())
  1222. return
  1223. }
  1224. // Pretty-print the response data.
  1225. fmt.Println(resp)
  1226. }
  1227. func ExampleS3_PutBucketNotification() {
  1228. sess, err := session.NewSession()
  1229. if err != nil {
  1230. fmt.Println("failed to create session,", err)
  1231. return
  1232. }
  1233. svc := s3.New(sess)
  1234. params := &s3.PutBucketNotificationInput{
  1235. Bucket: aws.String("BucketName"), // Required
  1236. NotificationConfiguration: &s3.NotificationConfigurationDeprecated{ // Required
  1237. CloudFunctionConfiguration: &s3.CloudFunctionConfiguration{
  1238. CloudFunction: aws.String("CloudFunction"),
  1239. Event: aws.String("Event"),
  1240. Events: []*string{
  1241. aws.String("Event"), // Required
  1242. // More values...
  1243. },
  1244. Id: aws.String("NotificationId"),
  1245. InvocationRole: aws.String("CloudFunctionInvocationRole"),
  1246. },
  1247. QueueConfiguration: &s3.QueueConfigurationDeprecated{
  1248. Event: aws.String("Event"),
  1249. Events: []*string{
  1250. aws.String("Event"), // Required
  1251. // More values...
  1252. },
  1253. Id: aws.String("NotificationId"),
  1254. Queue: aws.String("QueueArn"),
  1255. },
  1256. TopicConfiguration: &s3.TopicConfigurationDeprecated{
  1257. Event: aws.String("Event"),
  1258. Events: []*string{
  1259. aws.String("Event"), // Required
  1260. // More values...
  1261. },
  1262. Id: aws.String("NotificationId"),
  1263. Topic: aws.String("TopicArn"),
  1264. },
  1265. },
  1266. }
  1267. resp, err := svc.PutBucketNotification(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_PutBucketNotificationConfiguration() {
  1278. sess, err := session.NewSession()
  1279. if err != nil {
  1280. fmt.Println("failed to create session,", err)
  1281. return
  1282. }
  1283. svc := s3.New(sess)
  1284. params := &s3.PutBucketNotificationConfigurationInput{
  1285. Bucket: aws.String("BucketName"), // Required
  1286. NotificationConfiguration: &s3.NotificationConfiguration{ // Required
  1287. LambdaFunctionConfigurations: []*s3.LambdaFunctionConfiguration{
  1288. { // Required
  1289. Events: []*string{ // Required
  1290. aws.String("Event"), // Required
  1291. // More values...
  1292. },
  1293. LambdaFunctionArn: aws.String("LambdaFunctionArn"), // Required
  1294. Filter: &s3.NotificationConfigurationFilter{
  1295. Key: &s3.KeyFilter{
  1296. FilterRules: []*s3.FilterRule{
  1297. { // Required
  1298. Name: aws.String("FilterRuleName"),
  1299. Value: aws.String("FilterRuleValue"),
  1300. },
  1301. // More values...
  1302. },
  1303. },
  1304. },
  1305. Id: aws.String("NotificationId"),
  1306. },
  1307. // More values...
  1308. },
  1309. QueueConfigurations: []*s3.QueueConfiguration{
  1310. { // Required
  1311. Events: []*string{ // Required
  1312. aws.String("Event"), // Required
  1313. // More values...
  1314. },
  1315. QueueArn: aws.String("QueueArn"), // Required
  1316. Filter: &s3.NotificationConfigurationFilter{
  1317. Key: &s3.KeyFilter{
  1318. FilterRules: []*s3.FilterRule{
  1319. { // Required
  1320. Name: aws.String("FilterRuleName"),
  1321. Value: aws.String("FilterRuleValue"),
  1322. },
  1323. // More values...
  1324. },
  1325. },
  1326. },
  1327. Id: aws.String("NotificationId"),
  1328. },
  1329. // More values...
  1330. },
  1331. TopicConfigurations: []*s3.TopicConfiguration{
  1332. { // Required
  1333. Events: []*string{ // Required
  1334. aws.String("Event"), // Required
  1335. // More values...
  1336. },
  1337. TopicArn: aws.String("TopicArn"), // Required
  1338. Filter: &s3.NotificationConfigurationFilter{
  1339. Key: &s3.KeyFilter{
  1340. FilterRules: []*s3.FilterRule{
  1341. { // Required
  1342. Name: aws.String("FilterRuleName"),
  1343. Value: aws.String("FilterRuleValue"),
  1344. },
  1345. // More values...
  1346. },
  1347. },
  1348. },
  1349. Id: aws.String("NotificationId"),
  1350. },
  1351. // More values...
  1352. },
  1353. },
  1354. }
  1355. resp, err := svc.PutBucketNotificationConfiguration(params)
  1356. if err != nil {
  1357. // Print the error, cast err to awserr.Error to get the Code and
  1358. // Message from an error.
  1359. fmt.Println(err.Error())
  1360. return
  1361. }
  1362. // Pretty-print the response data.
  1363. fmt.Println(resp)
  1364. }
  1365. func ExampleS3_PutBucketPolicy() {
  1366. sess, err := session.NewSession()
  1367. if err != nil {
  1368. fmt.Println("failed to create session,", err)
  1369. return
  1370. }
  1371. svc := s3.New(sess)
  1372. params := &s3.PutBucketPolicyInput{
  1373. Bucket: aws.String("BucketName"), // Required
  1374. Policy: aws.String("Policy"), // Required
  1375. }
  1376. resp, err := svc.PutBucketPolicy(params)
  1377. if err != nil {
  1378. // Print the error, cast err to awserr.Error to get the Code and
  1379. // Message from an error.
  1380. fmt.Println(err.Error())
  1381. return
  1382. }
  1383. // Pretty-print the response data.
  1384. fmt.Println(resp)
  1385. }
  1386. func ExampleS3_PutBucketReplication() {
  1387. sess, err := session.NewSession()
  1388. if err != nil {
  1389. fmt.Println("failed to create session,", err)
  1390. return
  1391. }
  1392. svc := s3.New(sess)
  1393. params := &s3.PutBucketReplicationInput{
  1394. Bucket: aws.String("BucketName"), // Required
  1395. ReplicationConfiguration: &s3.ReplicationConfiguration{ // Required
  1396. Role: aws.String("Role"), // Required
  1397. Rules: []*s3.ReplicationRule{ // Required
  1398. { // Required
  1399. Destination: &s3.Destination{ // Required
  1400. Bucket: aws.String("BucketName"), // Required
  1401. StorageClass: aws.String("StorageClass"),
  1402. },
  1403. Prefix: aws.String("Prefix"), // Required
  1404. Status: aws.String("ReplicationRuleStatus"), // Required
  1405. ID: aws.String("ID"),
  1406. },
  1407. // More values...
  1408. },
  1409. },
  1410. }
  1411. resp, err := svc.PutBucketReplication(params)
  1412. if err != nil {
  1413. // Print the error, cast err to awserr.Error to get the Code and
  1414. // Message from an error.
  1415. fmt.Println(err.Error())
  1416. return
  1417. }
  1418. // Pretty-print the response data.
  1419. fmt.Println(resp)
  1420. }
  1421. func ExampleS3_PutBucketRequestPayment() {
  1422. sess, err := session.NewSession()
  1423. if err != nil {
  1424. fmt.Println("failed to create session,", err)
  1425. return
  1426. }
  1427. svc := s3.New(sess)
  1428. params := &s3.PutBucketRequestPaymentInput{
  1429. Bucket: aws.String("BucketName"), // Required
  1430. RequestPaymentConfiguration: &s3.RequestPaymentConfiguration{ // Required
  1431. Payer: aws.String("Payer"), // Required
  1432. },
  1433. }
  1434. resp, err := svc.PutBucketRequestPayment(params)
  1435. if err != nil {
  1436. // Print the error, cast err to awserr.Error to get the Code and
  1437. // Message from an error.
  1438. fmt.Println(err.Error())
  1439. return
  1440. }
  1441. // Pretty-print the response data.
  1442. fmt.Println(resp)
  1443. }
  1444. func ExampleS3_PutBucketTagging() {
  1445. sess, err := session.NewSession()
  1446. if err != nil {
  1447. fmt.Println("failed to create session,", err)
  1448. return
  1449. }
  1450. svc := s3.New(sess)
  1451. params := &s3.PutBucketTaggingInput{
  1452. Bucket: aws.String("BucketName"), // Required
  1453. Tagging: &s3.Tagging{ // Required
  1454. TagSet: []*s3.Tag{ // Required
  1455. { // Required
  1456. Key: aws.String("ObjectKey"), // Required
  1457. Value: aws.String("Value"), // Required
  1458. },
  1459. // More values...
  1460. },
  1461. },
  1462. }
  1463. resp, err := svc.PutBucketTagging(params)
  1464. if err != nil {
  1465. // Print the error, cast err to awserr.Error to get the Code and
  1466. // Message from an error.
  1467. fmt.Println(err.Error())
  1468. return
  1469. }
  1470. // Pretty-print the response data.
  1471. fmt.Println(resp)
  1472. }
  1473. func ExampleS3_PutBucketVersioning() {
  1474. sess, err := session.NewSession()
  1475. if err != nil {
  1476. fmt.Println("failed to create session,", err)
  1477. return
  1478. }
  1479. svc := s3.New(sess)
  1480. params := &s3.PutBucketVersioningInput{
  1481. Bucket: aws.String("BucketName"), // Required
  1482. VersioningConfiguration: &s3.VersioningConfiguration{ // Required
  1483. MFADelete: aws.String("MFADelete"),
  1484. Status: aws.String("BucketVersioningStatus"),
  1485. },
  1486. MFA: aws.String("MFA"),
  1487. }
  1488. resp, err := svc.PutBucketVersioning(params)
  1489. if err != nil {
  1490. // Print the error, cast err to awserr.Error to get the Code and
  1491. // Message from an error.
  1492. fmt.Println(err.Error())
  1493. return
  1494. }
  1495. // Pretty-print the response data.
  1496. fmt.Println(resp)
  1497. }
  1498. func ExampleS3_PutBucketWebsite() {
  1499. sess, err := session.NewSession()
  1500. if err != nil {
  1501. fmt.Println("failed to create session,", err)
  1502. return
  1503. }
  1504. svc := s3.New(sess)
  1505. params := &s3.PutBucketWebsiteInput{
  1506. Bucket: aws.String("BucketName"), // Required
  1507. WebsiteConfiguration: &s3.WebsiteConfiguration{ // Required
  1508. ErrorDocument: &s3.ErrorDocument{
  1509. Key: aws.String("ObjectKey"), // Required
  1510. },
  1511. IndexDocument: &s3.IndexDocument{
  1512. Suffix: aws.String("Suffix"), // Required
  1513. },
  1514. RedirectAllRequestsTo: &s3.RedirectAllRequestsTo{
  1515. HostName: aws.String("HostName"), // Required
  1516. Protocol: aws.String("Protocol"),
  1517. },
  1518. RoutingRules: []*s3.RoutingRule{
  1519. { // Required
  1520. Redirect: &s3.Redirect{ // Required
  1521. HostName: aws.String("HostName"),
  1522. HttpRedirectCode: aws.String("HttpRedirectCode"),
  1523. Protocol: aws.String("Protocol"),
  1524. ReplaceKeyPrefixWith: aws.String("ReplaceKeyPrefixWith"),
  1525. ReplaceKeyWith: aws.String("ReplaceKeyWith"),
  1526. },
  1527. Condition: &s3.Condition{
  1528. HttpErrorCodeReturnedEquals: aws.String("HttpErrorCodeReturnedEquals"),
  1529. KeyPrefixEquals: aws.String("KeyPrefixEquals"),
  1530. },
  1531. },
  1532. // More values...
  1533. },
  1534. },
  1535. }
  1536. resp, err := svc.PutBucketWebsite(params)
  1537. if err != nil {
  1538. // Print the error, cast err to awserr.Error to get the Code and
  1539. // Message from an error.
  1540. fmt.Println(err.Error())
  1541. return
  1542. }
  1543. // Pretty-print the response data.
  1544. fmt.Println(resp)
  1545. }
  1546. func ExampleS3_PutObject() {
  1547. sess, err := session.NewSession()
  1548. if err != nil {
  1549. fmt.Println("failed to create session,", err)
  1550. return
  1551. }
  1552. svc := s3.New(sess)
  1553. params := &s3.PutObjectInput{
  1554. Bucket: aws.String("BucketName"), // Required
  1555. Key: aws.String("ObjectKey"), // Required
  1556. ACL: aws.String("ObjectCannedACL"),
  1557. Body: bytes.NewReader([]byte("PAYLOAD")),
  1558. CacheControl: aws.String("CacheControl"),
  1559. ContentDisposition: aws.String("ContentDisposition"),
  1560. ContentEncoding: aws.String("ContentEncoding"),
  1561. ContentLanguage: aws.String("ContentLanguage"),
  1562. ContentLength: aws.Int64(1),
  1563. ContentType: aws.String("ContentType"),
  1564. Expires: aws.Time(time.Now()),
  1565. GrantFullControl: aws.String("GrantFullControl"),
  1566. GrantRead: aws.String("GrantRead"),
  1567. GrantReadACP: aws.String("GrantReadACP"),
  1568. GrantWriteACP: aws.String("GrantWriteACP"),
  1569. Metadata: map[string]*string{
  1570. "Key": aws.String("MetadataValue"), // Required
  1571. // More values...
  1572. },
  1573. RequestPayer: aws.String("RequestPayer"),
  1574. SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
  1575. SSECustomerKey: aws.String("SSECustomerKey"),
  1576. SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
  1577. SSEKMSKeyId: aws.String("SSEKMSKeyId"),
  1578. ServerSideEncryption: aws.String("ServerSideEncryption"),
  1579. StorageClass: aws.String("StorageClass"),
  1580. WebsiteRedirectLocation: aws.String("WebsiteRedirectLocation"),
  1581. }
  1582. resp, err := svc.PutObject(params)
  1583. if err != nil {
  1584. // Print the error, cast err to awserr.Error to get the Code and
  1585. // Message from an error.
  1586. fmt.Println(err.Error())
  1587. return
  1588. }
  1589. // Pretty-print the response data.
  1590. fmt.Println(resp)
  1591. }
  1592. func ExampleS3_PutObjectAcl() {
  1593. sess, err := session.NewSession()
  1594. if err != nil {
  1595. fmt.Println("failed to create session,", err)
  1596. return
  1597. }
  1598. svc := s3.New(sess)
  1599. params := &s3.PutObjectAclInput{
  1600. Bucket: aws.String("BucketName"), // Required
  1601. Key: aws.String("ObjectKey"), // Required
  1602. ACL: aws.String("ObjectCannedACL"),
  1603. AccessControlPolicy: &s3.AccessControlPolicy{
  1604. Grants: []*s3.Grant{
  1605. { // Required
  1606. Grantee: &s3.Grantee{
  1607. Type: aws.String("Type"), // Required
  1608. DisplayName: aws.String("DisplayName"),
  1609. EmailAddress: aws.String("EmailAddress"),
  1610. ID: aws.String("ID"),
  1611. URI: aws.String("URI"),
  1612. },
  1613. Permission: aws.String("Permission"),
  1614. },
  1615. // More values...
  1616. },
  1617. Owner: &s3.Owner{
  1618. DisplayName: aws.String("DisplayName"),
  1619. ID: aws.String("ID"),
  1620. },
  1621. },
  1622. GrantFullControl: aws.String("GrantFullControl"),
  1623. GrantRead: aws.String("GrantRead"),
  1624. GrantReadACP: aws.String("GrantReadACP"),
  1625. GrantWrite: aws.String("GrantWrite"),
  1626. GrantWriteACP: aws.String("GrantWriteACP"),
  1627. RequestPayer: aws.String("RequestPayer"),
  1628. VersionId: aws.String("ObjectVersionId"),
  1629. }
  1630. resp, err := svc.PutObjectAcl(params)
  1631. if err != nil {
  1632. // Print the error, cast err to awserr.Error to get the Code and
  1633. // Message from an error.
  1634. fmt.Println(err.Error())
  1635. return
  1636. }
  1637. // Pretty-print the response data.
  1638. fmt.Println(resp)
  1639. }
  1640. func ExampleS3_RestoreObject() {
  1641. sess, err := session.NewSession()
  1642. if err != nil {
  1643. fmt.Println("failed to create session,", err)
  1644. return
  1645. }
  1646. svc := s3.New(sess)
  1647. params := &s3.RestoreObjectInput{
  1648. Bucket: aws.String("BucketName"), // Required
  1649. Key: aws.String("ObjectKey"), // Required
  1650. RequestPayer: aws.String("RequestPayer"),
  1651. RestoreRequest: &s3.RestoreRequest{
  1652. Days: aws.Int64(1), // Required
  1653. },
  1654. VersionId: aws.String("ObjectVersionId"),
  1655. }
  1656. resp, err := svc.RestoreObject(params)
  1657. if err != nil {
  1658. // Print the error, cast err to awserr.Error to get the Code and
  1659. // Message from an error.
  1660. fmt.Println(err.Error())
  1661. return
  1662. }
  1663. // Pretty-print the response data.
  1664. fmt.Println(resp)
  1665. }
  1666. func ExampleS3_UploadPart() {
  1667. sess, err := session.NewSession()
  1668. if err != nil {
  1669. fmt.Println("failed to create session,", err)
  1670. return
  1671. }
  1672. svc := s3.New(sess)
  1673. params := &s3.UploadPartInput{
  1674. Bucket: aws.String("BucketName"), // Required
  1675. Key: aws.String("ObjectKey"), // Required
  1676. PartNumber: aws.Int64(1), // Required
  1677. UploadId: aws.String("MultipartUploadId"), // Required
  1678. Body: bytes.NewReader([]byte("PAYLOAD")),
  1679. ContentLength: aws.Int64(1),
  1680. RequestPayer: aws.String("RequestPayer"),
  1681. SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
  1682. SSECustomerKey: aws.String("SSECustomerKey"),
  1683. SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
  1684. }
  1685. resp, err := svc.UploadPart(params)
  1686. if err != nil {
  1687. // Print the error, cast err to awserr.Error to get the Code and
  1688. // Message from an error.
  1689. fmt.Println(err.Error())
  1690. return
  1691. }
  1692. // Pretty-print the response data.
  1693. fmt.Println(resp)
  1694. }
  1695. func ExampleS3_UploadPartCopy() {
  1696. sess, err := session.NewSession()
  1697. if err != nil {
  1698. fmt.Println("failed to create session,", err)
  1699. return
  1700. }
  1701. svc := s3.New(sess)
  1702. params := &s3.UploadPartCopyInput{
  1703. Bucket: aws.String("BucketName"), // Required
  1704. CopySource: aws.String("CopySource"), // Required
  1705. Key: aws.String("ObjectKey"), // Required
  1706. PartNumber: aws.Int64(1), // Required
  1707. UploadId: aws.String("MultipartUploadId"), // Required
  1708. CopySourceIfMatch: aws.String("CopySourceIfMatch"),
  1709. CopySourceIfModifiedSince: aws.Time(time.Now()),
  1710. CopySourceIfNoneMatch: aws.String("CopySourceIfNoneMatch"),
  1711. CopySourceIfUnmodifiedSince: aws.Time(time.Now()),
  1712. CopySourceRange: aws.String("CopySourceRange"),
  1713. CopySourceSSECustomerAlgorithm: aws.String("CopySourceSSECustomerAlgorithm"),
  1714. CopySourceSSECustomerKey: aws.String("CopySourceSSECustomerKey"),
  1715. CopySourceSSECustomerKeyMD5: aws.String("CopySourceSSECustomerKeyMD5"),
  1716. RequestPayer: aws.String("RequestPayer"),
  1717. SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
  1718. SSECustomerKey: aws.String("SSECustomerKey"),
  1719. SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
  1720. }
  1721. resp, err := svc.UploadPartCopy(params)
  1722. if err != nil {
  1723. // Print the error, cast err to awserr.Error to get the Code and
  1724. // Message from an error.
  1725. fmt.Println(err.Error())
  1726. return
  1727. }
  1728. // Pretty-print the response data.
  1729. fmt.Println(resp)
  1730. }