examples_test.go 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033
  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. PartNumber: aws.Int64(1),
  705. Range: aws.String("Range"),
  706. RequestPayer: aws.String("RequestPayer"),
  707. ResponseCacheControl: aws.String("ResponseCacheControl"),
  708. ResponseContentDisposition: aws.String("ResponseContentDisposition"),
  709. ResponseContentEncoding: aws.String("ResponseContentEncoding"),
  710. ResponseContentLanguage: aws.String("ResponseContentLanguage"),
  711. ResponseContentType: aws.String("ResponseContentType"),
  712. ResponseExpires: aws.Time(time.Now()),
  713. SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
  714. SSECustomerKey: aws.String("SSECustomerKey"),
  715. SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
  716. VersionId: aws.String("ObjectVersionId"),
  717. }
  718. resp, err := svc.GetObject(params)
  719. if err != nil {
  720. // Print the error, cast err to awserr.Error to get the Code and
  721. // Message from an error.
  722. fmt.Println(err.Error())
  723. return
  724. }
  725. // Pretty-print the response data.
  726. fmt.Println(resp)
  727. }
  728. func ExampleS3_GetObjectAcl() {
  729. sess, err := session.NewSession()
  730. if err != nil {
  731. fmt.Println("failed to create session,", err)
  732. return
  733. }
  734. svc := s3.New(sess)
  735. params := &s3.GetObjectAclInput{
  736. Bucket: aws.String("BucketName"), // Required
  737. Key: aws.String("ObjectKey"), // Required
  738. RequestPayer: aws.String("RequestPayer"),
  739. VersionId: aws.String("ObjectVersionId"),
  740. }
  741. resp, err := svc.GetObjectAcl(params)
  742. if err != nil {
  743. // Print the error, cast err to awserr.Error to get the Code and
  744. // Message from an error.
  745. fmt.Println(err.Error())
  746. return
  747. }
  748. // Pretty-print the response data.
  749. fmt.Println(resp)
  750. }
  751. func ExampleS3_GetObjectTorrent() {
  752. sess, err := session.NewSession()
  753. if err != nil {
  754. fmt.Println("failed to create session,", err)
  755. return
  756. }
  757. svc := s3.New(sess)
  758. params := &s3.GetObjectTorrentInput{
  759. Bucket: aws.String("BucketName"), // Required
  760. Key: aws.String("ObjectKey"), // Required
  761. RequestPayer: aws.String("RequestPayer"),
  762. }
  763. resp, err := svc.GetObjectTorrent(params)
  764. if err != nil {
  765. // Print the error, cast err to awserr.Error to get the Code and
  766. // Message from an error.
  767. fmt.Println(err.Error())
  768. return
  769. }
  770. // Pretty-print the response data.
  771. fmt.Println(resp)
  772. }
  773. func ExampleS3_HeadBucket() {
  774. sess, err := session.NewSession()
  775. if err != nil {
  776. fmt.Println("failed to create session,", err)
  777. return
  778. }
  779. svc := s3.New(sess)
  780. params := &s3.HeadBucketInput{
  781. Bucket: aws.String("BucketName"), // Required
  782. }
  783. resp, err := svc.HeadBucket(params)
  784. if err != nil {
  785. // Print the error, cast err to awserr.Error to get the Code and
  786. // Message from an error.
  787. fmt.Println(err.Error())
  788. return
  789. }
  790. // Pretty-print the response data.
  791. fmt.Println(resp)
  792. }
  793. func ExampleS3_HeadObject() {
  794. sess, err := session.NewSession()
  795. if err != nil {
  796. fmt.Println("failed to create session,", err)
  797. return
  798. }
  799. svc := s3.New(sess)
  800. params := &s3.HeadObjectInput{
  801. Bucket: aws.String("BucketName"), // Required
  802. Key: aws.String("ObjectKey"), // Required
  803. IfMatch: aws.String("IfMatch"),
  804. IfModifiedSince: aws.Time(time.Now()),
  805. IfNoneMatch: aws.String("IfNoneMatch"),
  806. IfUnmodifiedSince: aws.Time(time.Now()),
  807. PartNumber: aws.Int64(1),
  808. Range: aws.String("Range"),
  809. RequestPayer: aws.String("RequestPayer"),
  810. SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
  811. SSECustomerKey: aws.String("SSECustomerKey"),
  812. SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
  813. VersionId: aws.String("ObjectVersionId"),
  814. }
  815. resp, err := svc.HeadObject(params)
  816. if err != nil {
  817. // Print the error, cast err to awserr.Error to get the Code and
  818. // Message from an error.
  819. fmt.Println(err.Error())
  820. return
  821. }
  822. // Pretty-print the response data.
  823. fmt.Println(resp)
  824. }
  825. func ExampleS3_ListBuckets() {
  826. sess, err := session.NewSession()
  827. if err != nil {
  828. fmt.Println("failed to create session,", err)
  829. return
  830. }
  831. svc := s3.New(sess)
  832. var params *s3.ListBucketsInput
  833. resp, err := svc.ListBuckets(params)
  834. if err != nil {
  835. // Print the error, cast err to awserr.Error to get the Code and
  836. // Message from an error.
  837. fmt.Println(err.Error())
  838. return
  839. }
  840. // Pretty-print the response data.
  841. fmt.Println(resp)
  842. }
  843. func ExampleS3_ListMultipartUploads() {
  844. sess, err := session.NewSession()
  845. if err != nil {
  846. fmt.Println("failed to create session,", err)
  847. return
  848. }
  849. svc := s3.New(sess)
  850. params := &s3.ListMultipartUploadsInput{
  851. Bucket: aws.String("BucketName"), // Required
  852. Delimiter: aws.String("Delimiter"),
  853. EncodingType: aws.String("EncodingType"),
  854. KeyMarker: aws.String("KeyMarker"),
  855. MaxUploads: aws.Int64(1),
  856. Prefix: aws.String("Prefix"),
  857. UploadIdMarker: aws.String("UploadIdMarker"),
  858. }
  859. resp, err := svc.ListMultipartUploads(params)
  860. if err != nil {
  861. // Print the error, cast err to awserr.Error to get the Code and
  862. // Message from an error.
  863. fmt.Println(err.Error())
  864. return
  865. }
  866. // Pretty-print the response data.
  867. fmt.Println(resp)
  868. }
  869. func ExampleS3_ListObjectVersions() {
  870. sess, err := session.NewSession()
  871. if err != nil {
  872. fmt.Println("failed to create session,", err)
  873. return
  874. }
  875. svc := s3.New(sess)
  876. params := &s3.ListObjectVersionsInput{
  877. Bucket: aws.String("BucketName"), // Required
  878. Delimiter: aws.String("Delimiter"),
  879. EncodingType: aws.String("EncodingType"),
  880. KeyMarker: aws.String("KeyMarker"),
  881. MaxKeys: aws.Int64(1),
  882. Prefix: aws.String("Prefix"),
  883. VersionIdMarker: aws.String("VersionIdMarker"),
  884. }
  885. resp, err := svc.ListObjectVersions(params)
  886. if err != nil {
  887. // Print the error, cast err to awserr.Error to get the Code and
  888. // Message from an error.
  889. fmt.Println(err.Error())
  890. return
  891. }
  892. // Pretty-print the response data.
  893. fmt.Println(resp)
  894. }
  895. func ExampleS3_ListObjects() {
  896. sess, err := session.NewSession()
  897. if err != nil {
  898. fmt.Println("failed to create session,", err)
  899. return
  900. }
  901. svc := s3.New(sess)
  902. params := &s3.ListObjectsInput{
  903. Bucket: aws.String("BucketName"), // Required
  904. Delimiter: aws.String("Delimiter"),
  905. EncodingType: aws.String("EncodingType"),
  906. Marker: aws.String("Marker"),
  907. MaxKeys: aws.Int64(1),
  908. Prefix: aws.String("Prefix"),
  909. RequestPayer: aws.String("RequestPayer"),
  910. }
  911. resp, err := svc.ListObjects(params)
  912. if err != nil {
  913. // Print the error, cast err to awserr.Error to get the Code and
  914. // Message from an error.
  915. fmt.Println(err.Error())
  916. return
  917. }
  918. // Pretty-print the response data.
  919. fmt.Println(resp)
  920. }
  921. func ExampleS3_ListObjectsV2() {
  922. sess, err := session.NewSession()
  923. if err != nil {
  924. fmt.Println("failed to create session,", err)
  925. return
  926. }
  927. svc := s3.New(sess)
  928. params := &s3.ListObjectsV2Input{
  929. Bucket: aws.String("BucketName"), // Required
  930. ContinuationToken: aws.String("Token"),
  931. Delimiter: aws.String("Delimiter"),
  932. EncodingType: aws.String("EncodingType"),
  933. FetchOwner: aws.Bool(true),
  934. MaxKeys: aws.Int64(1),
  935. Prefix: aws.String("Prefix"),
  936. RequestPayer: aws.String("RequestPayer"),
  937. StartAfter: aws.String("StartAfter"),
  938. }
  939. resp, err := svc.ListObjectsV2(params)
  940. if err != nil {
  941. // Print the error, cast err to awserr.Error to get the Code and
  942. // Message from an error.
  943. fmt.Println(err.Error())
  944. return
  945. }
  946. // Pretty-print the response data.
  947. fmt.Println(resp)
  948. }
  949. func ExampleS3_ListParts() {
  950. sess, err := session.NewSession()
  951. if err != nil {
  952. fmt.Println("failed to create session,", err)
  953. return
  954. }
  955. svc := s3.New(sess)
  956. params := &s3.ListPartsInput{
  957. Bucket: aws.String("BucketName"), // Required
  958. Key: aws.String("ObjectKey"), // Required
  959. UploadId: aws.String("MultipartUploadId"), // Required
  960. MaxParts: aws.Int64(1),
  961. PartNumberMarker: aws.Int64(1),
  962. RequestPayer: aws.String("RequestPayer"),
  963. }
  964. resp, err := svc.ListParts(params)
  965. if err != nil {
  966. // Print the error, cast err to awserr.Error to get the Code and
  967. // Message from an error.
  968. fmt.Println(err.Error())
  969. return
  970. }
  971. // Pretty-print the response data.
  972. fmt.Println(resp)
  973. }
  974. func ExampleS3_PutBucketAccelerateConfiguration() {
  975. sess, err := session.NewSession()
  976. if err != nil {
  977. fmt.Println("failed to create session,", err)
  978. return
  979. }
  980. svc := s3.New(sess)
  981. params := &s3.PutBucketAccelerateConfigurationInput{
  982. AccelerateConfiguration: &s3.AccelerateConfiguration{ // Required
  983. Status: aws.String("BucketAccelerateStatus"),
  984. },
  985. Bucket: aws.String("BucketName"), // Required
  986. }
  987. resp, err := svc.PutBucketAccelerateConfiguration(params)
  988. if err != nil {
  989. // Print the error, cast err to awserr.Error to get the Code and
  990. // Message from an error.
  991. fmt.Println(err.Error())
  992. return
  993. }
  994. // Pretty-print the response data.
  995. fmt.Println(resp)
  996. }
  997. func ExampleS3_PutBucketAcl() {
  998. sess, err := session.NewSession()
  999. if err != nil {
  1000. fmt.Println("failed to create session,", err)
  1001. return
  1002. }
  1003. svc := s3.New(sess)
  1004. params := &s3.PutBucketAclInput{
  1005. Bucket: aws.String("BucketName"), // Required
  1006. ACL: aws.String("BucketCannedACL"),
  1007. AccessControlPolicy: &s3.AccessControlPolicy{
  1008. Grants: []*s3.Grant{
  1009. { // Required
  1010. Grantee: &s3.Grantee{
  1011. Type: aws.String("Type"), // Required
  1012. DisplayName: aws.String("DisplayName"),
  1013. EmailAddress: aws.String("EmailAddress"),
  1014. ID: aws.String("ID"),
  1015. URI: aws.String("URI"),
  1016. },
  1017. Permission: aws.String("Permission"),
  1018. },
  1019. // More values...
  1020. },
  1021. Owner: &s3.Owner{
  1022. DisplayName: aws.String("DisplayName"),
  1023. ID: aws.String("ID"),
  1024. },
  1025. },
  1026. GrantFullControl: aws.String("GrantFullControl"),
  1027. GrantRead: aws.String("GrantRead"),
  1028. GrantReadACP: aws.String("GrantReadACP"),
  1029. GrantWrite: aws.String("GrantWrite"),
  1030. GrantWriteACP: aws.String("GrantWriteACP"),
  1031. }
  1032. resp, err := svc.PutBucketAcl(params)
  1033. if err != nil {
  1034. // Print the error, cast err to awserr.Error to get the Code and
  1035. // Message from an error.
  1036. fmt.Println(err.Error())
  1037. return
  1038. }
  1039. // Pretty-print the response data.
  1040. fmt.Println(resp)
  1041. }
  1042. func ExampleS3_PutBucketCors() {
  1043. sess, err := session.NewSession()
  1044. if err != nil {
  1045. fmt.Println("failed to create session,", err)
  1046. return
  1047. }
  1048. svc := s3.New(sess)
  1049. params := &s3.PutBucketCorsInput{
  1050. Bucket: aws.String("BucketName"), // Required
  1051. CORSConfiguration: &s3.CORSConfiguration{ // Required
  1052. CORSRules: []*s3.CORSRule{ // Required
  1053. { // Required
  1054. AllowedMethods: []*string{ // Required
  1055. aws.String("AllowedMethod"), // Required
  1056. // More values...
  1057. },
  1058. AllowedOrigins: []*string{ // Required
  1059. aws.String("AllowedOrigin"), // Required
  1060. // More values...
  1061. },
  1062. AllowedHeaders: []*string{
  1063. aws.String("AllowedHeader"), // Required
  1064. // More values...
  1065. },
  1066. ExposeHeaders: []*string{
  1067. aws.String("ExposeHeader"), // Required
  1068. // More values...
  1069. },
  1070. MaxAgeSeconds: aws.Int64(1),
  1071. },
  1072. // More values...
  1073. },
  1074. },
  1075. }
  1076. resp, err := svc.PutBucketCors(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_PutBucketLifecycle() {
  1087. sess, err := session.NewSession()
  1088. if err != nil {
  1089. fmt.Println("failed to create session,", err)
  1090. return
  1091. }
  1092. svc := s3.New(sess)
  1093. params := &s3.PutBucketLifecycleInput{
  1094. Bucket: aws.String("BucketName"), // Required
  1095. LifecycleConfiguration: &s3.LifecycleConfiguration{
  1096. Rules: []*s3.Rule{ // Required
  1097. { // Required
  1098. Prefix: aws.String("Prefix"), // Required
  1099. Status: aws.String("ExpirationStatus"), // Required
  1100. AbortIncompleteMultipartUpload: &s3.AbortIncompleteMultipartUpload{
  1101. DaysAfterInitiation: aws.Int64(1),
  1102. },
  1103. Expiration: &s3.LifecycleExpiration{
  1104. Date: aws.Time(time.Now()),
  1105. Days: aws.Int64(1),
  1106. ExpiredObjectDeleteMarker: aws.Bool(true),
  1107. },
  1108. ID: aws.String("ID"),
  1109. NoncurrentVersionExpiration: &s3.NoncurrentVersionExpiration{
  1110. NoncurrentDays: aws.Int64(1),
  1111. },
  1112. NoncurrentVersionTransition: &s3.NoncurrentVersionTransition{
  1113. NoncurrentDays: aws.Int64(1),
  1114. StorageClass: aws.String("TransitionStorageClass"),
  1115. },
  1116. Transition: &s3.Transition{
  1117. Date: aws.Time(time.Now()),
  1118. Days: aws.Int64(1),
  1119. StorageClass: aws.String("TransitionStorageClass"),
  1120. },
  1121. },
  1122. // More values...
  1123. },
  1124. },
  1125. }
  1126. resp, err := svc.PutBucketLifecycle(params)
  1127. if err != nil {
  1128. // Print the error, cast err to awserr.Error to get the Code and
  1129. // Message from an error.
  1130. fmt.Println(err.Error())
  1131. return
  1132. }
  1133. // Pretty-print the response data.
  1134. fmt.Println(resp)
  1135. }
  1136. func ExampleS3_PutBucketLifecycleConfiguration() {
  1137. sess, err := session.NewSession()
  1138. if err != nil {
  1139. fmt.Println("failed to create session,", err)
  1140. return
  1141. }
  1142. svc := s3.New(sess)
  1143. params := &s3.PutBucketLifecycleConfigurationInput{
  1144. Bucket: aws.String("BucketName"), // Required
  1145. LifecycleConfiguration: &s3.BucketLifecycleConfiguration{
  1146. Rules: []*s3.LifecycleRule{ // Required
  1147. { // Required
  1148. Prefix: aws.String("Prefix"), // Required
  1149. Status: aws.String("ExpirationStatus"), // Required
  1150. AbortIncompleteMultipartUpload: &s3.AbortIncompleteMultipartUpload{
  1151. DaysAfterInitiation: aws.Int64(1),
  1152. },
  1153. Expiration: &s3.LifecycleExpiration{
  1154. Date: aws.Time(time.Now()),
  1155. Days: aws.Int64(1),
  1156. ExpiredObjectDeleteMarker: aws.Bool(true),
  1157. },
  1158. ID: aws.String("ID"),
  1159. NoncurrentVersionExpiration: &s3.NoncurrentVersionExpiration{
  1160. NoncurrentDays: aws.Int64(1),
  1161. },
  1162. NoncurrentVersionTransitions: []*s3.NoncurrentVersionTransition{
  1163. { // Required
  1164. NoncurrentDays: aws.Int64(1),
  1165. StorageClass: aws.String("TransitionStorageClass"),
  1166. },
  1167. // More values...
  1168. },
  1169. Transitions: []*s3.Transition{
  1170. { // Required
  1171. Date: aws.Time(time.Now()),
  1172. Days: aws.Int64(1),
  1173. StorageClass: aws.String("TransitionStorageClass"),
  1174. },
  1175. // More values...
  1176. },
  1177. },
  1178. // More values...
  1179. },
  1180. },
  1181. }
  1182. resp, err := svc.PutBucketLifecycleConfiguration(params)
  1183. if err != nil {
  1184. // Print the error, cast err to awserr.Error to get the Code and
  1185. // Message from an error.
  1186. fmt.Println(err.Error())
  1187. return
  1188. }
  1189. // Pretty-print the response data.
  1190. fmt.Println(resp)
  1191. }
  1192. func ExampleS3_PutBucketLogging() {
  1193. sess, err := session.NewSession()
  1194. if err != nil {
  1195. fmt.Println("failed to create session,", err)
  1196. return
  1197. }
  1198. svc := s3.New(sess)
  1199. params := &s3.PutBucketLoggingInput{
  1200. Bucket: aws.String("BucketName"), // Required
  1201. BucketLoggingStatus: &s3.BucketLoggingStatus{ // Required
  1202. LoggingEnabled: &s3.LoggingEnabled{
  1203. TargetBucket: aws.String("TargetBucket"),
  1204. TargetGrants: []*s3.TargetGrant{
  1205. { // Required
  1206. Grantee: &s3.Grantee{
  1207. Type: aws.String("Type"), // Required
  1208. DisplayName: aws.String("DisplayName"),
  1209. EmailAddress: aws.String("EmailAddress"),
  1210. ID: aws.String("ID"),
  1211. URI: aws.String("URI"),
  1212. },
  1213. Permission: aws.String("BucketLogsPermission"),
  1214. },
  1215. // More values...
  1216. },
  1217. TargetPrefix: aws.String("TargetPrefix"),
  1218. },
  1219. },
  1220. }
  1221. resp, err := svc.PutBucketLogging(params)
  1222. if err != nil {
  1223. // Print the error, cast err to awserr.Error to get the Code and
  1224. // Message from an error.
  1225. fmt.Println(err.Error())
  1226. return
  1227. }
  1228. // Pretty-print the response data.
  1229. fmt.Println(resp)
  1230. }
  1231. func ExampleS3_PutBucketNotification() {
  1232. sess, err := session.NewSession()
  1233. if err != nil {
  1234. fmt.Println("failed to create session,", err)
  1235. return
  1236. }
  1237. svc := s3.New(sess)
  1238. params := &s3.PutBucketNotificationInput{
  1239. Bucket: aws.String("BucketName"), // Required
  1240. NotificationConfiguration: &s3.NotificationConfigurationDeprecated{ // Required
  1241. CloudFunctionConfiguration: &s3.CloudFunctionConfiguration{
  1242. CloudFunction: aws.String("CloudFunction"),
  1243. Event: aws.String("Event"),
  1244. Events: []*string{
  1245. aws.String("Event"), // Required
  1246. // More values...
  1247. },
  1248. Id: aws.String("NotificationId"),
  1249. InvocationRole: aws.String("CloudFunctionInvocationRole"),
  1250. },
  1251. QueueConfiguration: &s3.QueueConfigurationDeprecated{
  1252. Event: aws.String("Event"),
  1253. Events: []*string{
  1254. aws.String("Event"), // Required
  1255. // More values...
  1256. },
  1257. Id: aws.String("NotificationId"),
  1258. Queue: aws.String("QueueArn"),
  1259. },
  1260. TopicConfiguration: &s3.TopicConfigurationDeprecated{
  1261. Event: aws.String("Event"),
  1262. Events: []*string{
  1263. aws.String("Event"), // Required
  1264. // More values...
  1265. },
  1266. Id: aws.String("NotificationId"),
  1267. Topic: aws.String("TopicArn"),
  1268. },
  1269. },
  1270. }
  1271. resp, err := svc.PutBucketNotification(params)
  1272. if err != nil {
  1273. // Print the error, cast err to awserr.Error to get the Code and
  1274. // Message from an error.
  1275. fmt.Println(err.Error())
  1276. return
  1277. }
  1278. // Pretty-print the response data.
  1279. fmt.Println(resp)
  1280. }
  1281. func ExampleS3_PutBucketNotificationConfiguration() {
  1282. sess, err := session.NewSession()
  1283. if err != nil {
  1284. fmt.Println("failed to create session,", err)
  1285. return
  1286. }
  1287. svc := s3.New(sess)
  1288. params := &s3.PutBucketNotificationConfigurationInput{
  1289. Bucket: aws.String("BucketName"), // Required
  1290. NotificationConfiguration: &s3.NotificationConfiguration{ // Required
  1291. LambdaFunctionConfigurations: []*s3.LambdaFunctionConfiguration{
  1292. { // Required
  1293. Events: []*string{ // Required
  1294. aws.String("Event"), // Required
  1295. // More values...
  1296. },
  1297. LambdaFunctionArn: aws.String("LambdaFunctionArn"), // Required
  1298. Filter: &s3.NotificationConfigurationFilter{
  1299. Key: &s3.KeyFilter{
  1300. FilterRules: []*s3.FilterRule{
  1301. { // Required
  1302. Name: aws.String("FilterRuleName"),
  1303. Value: aws.String("FilterRuleValue"),
  1304. },
  1305. // More values...
  1306. },
  1307. },
  1308. },
  1309. Id: aws.String("NotificationId"),
  1310. },
  1311. // More values...
  1312. },
  1313. QueueConfigurations: []*s3.QueueConfiguration{
  1314. { // Required
  1315. Events: []*string{ // Required
  1316. aws.String("Event"), // Required
  1317. // More values...
  1318. },
  1319. QueueArn: aws.String("QueueArn"), // Required
  1320. Filter: &s3.NotificationConfigurationFilter{
  1321. Key: &s3.KeyFilter{
  1322. FilterRules: []*s3.FilterRule{
  1323. { // Required
  1324. Name: aws.String("FilterRuleName"),
  1325. Value: aws.String("FilterRuleValue"),
  1326. },
  1327. // More values...
  1328. },
  1329. },
  1330. },
  1331. Id: aws.String("NotificationId"),
  1332. },
  1333. // More values...
  1334. },
  1335. TopicConfigurations: []*s3.TopicConfiguration{
  1336. { // Required
  1337. Events: []*string{ // Required
  1338. aws.String("Event"), // Required
  1339. // More values...
  1340. },
  1341. TopicArn: aws.String("TopicArn"), // Required
  1342. Filter: &s3.NotificationConfigurationFilter{
  1343. Key: &s3.KeyFilter{
  1344. FilterRules: []*s3.FilterRule{
  1345. { // Required
  1346. Name: aws.String("FilterRuleName"),
  1347. Value: aws.String("FilterRuleValue"),
  1348. },
  1349. // More values...
  1350. },
  1351. },
  1352. },
  1353. Id: aws.String("NotificationId"),
  1354. },
  1355. // More values...
  1356. },
  1357. },
  1358. }
  1359. resp, err := svc.PutBucketNotificationConfiguration(params)
  1360. if err != nil {
  1361. // Print the error, cast err to awserr.Error to get the Code and
  1362. // Message from an error.
  1363. fmt.Println(err.Error())
  1364. return
  1365. }
  1366. // Pretty-print the response data.
  1367. fmt.Println(resp)
  1368. }
  1369. func ExampleS3_PutBucketPolicy() {
  1370. sess, err := session.NewSession()
  1371. if err != nil {
  1372. fmt.Println("failed to create session,", err)
  1373. return
  1374. }
  1375. svc := s3.New(sess)
  1376. params := &s3.PutBucketPolicyInput{
  1377. Bucket: aws.String("BucketName"), // Required
  1378. Policy: aws.String("Policy"), // Required
  1379. }
  1380. resp, err := svc.PutBucketPolicy(params)
  1381. if err != nil {
  1382. // Print the error, cast err to awserr.Error to get the Code and
  1383. // Message from an error.
  1384. fmt.Println(err.Error())
  1385. return
  1386. }
  1387. // Pretty-print the response data.
  1388. fmt.Println(resp)
  1389. }
  1390. func ExampleS3_PutBucketReplication() {
  1391. sess, err := session.NewSession()
  1392. if err != nil {
  1393. fmt.Println("failed to create session,", err)
  1394. return
  1395. }
  1396. svc := s3.New(sess)
  1397. params := &s3.PutBucketReplicationInput{
  1398. Bucket: aws.String("BucketName"), // Required
  1399. ReplicationConfiguration: &s3.ReplicationConfiguration{ // Required
  1400. Role: aws.String("Role"), // Required
  1401. Rules: []*s3.ReplicationRule{ // Required
  1402. { // Required
  1403. Destination: &s3.Destination{ // Required
  1404. Bucket: aws.String("BucketName"), // Required
  1405. StorageClass: aws.String("StorageClass"),
  1406. },
  1407. Prefix: aws.String("Prefix"), // Required
  1408. Status: aws.String("ReplicationRuleStatus"), // Required
  1409. ID: aws.String("ID"),
  1410. },
  1411. // More values...
  1412. },
  1413. },
  1414. }
  1415. resp, err := svc.PutBucketReplication(params)
  1416. if err != nil {
  1417. // Print the error, cast err to awserr.Error to get the Code and
  1418. // Message from an error.
  1419. fmt.Println(err.Error())
  1420. return
  1421. }
  1422. // Pretty-print the response data.
  1423. fmt.Println(resp)
  1424. }
  1425. func ExampleS3_PutBucketRequestPayment() {
  1426. sess, err := session.NewSession()
  1427. if err != nil {
  1428. fmt.Println("failed to create session,", err)
  1429. return
  1430. }
  1431. svc := s3.New(sess)
  1432. params := &s3.PutBucketRequestPaymentInput{
  1433. Bucket: aws.String("BucketName"), // Required
  1434. RequestPaymentConfiguration: &s3.RequestPaymentConfiguration{ // Required
  1435. Payer: aws.String("Payer"), // Required
  1436. },
  1437. }
  1438. resp, err := svc.PutBucketRequestPayment(params)
  1439. if err != nil {
  1440. // Print the error, cast err to awserr.Error to get the Code and
  1441. // Message from an error.
  1442. fmt.Println(err.Error())
  1443. return
  1444. }
  1445. // Pretty-print the response data.
  1446. fmt.Println(resp)
  1447. }
  1448. func ExampleS3_PutBucketTagging() {
  1449. sess, err := session.NewSession()
  1450. if err != nil {
  1451. fmt.Println("failed to create session,", err)
  1452. return
  1453. }
  1454. svc := s3.New(sess)
  1455. params := &s3.PutBucketTaggingInput{
  1456. Bucket: aws.String("BucketName"), // Required
  1457. Tagging: &s3.Tagging{ // Required
  1458. TagSet: []*s3.Tag{ // Required
  1459. { // Required
  1460. Key: aws.String("ObjectKey"), // Required
  1461. Value: aws.String("Value"), // Required
  1462. },
  1463. // More values...
  1464. },
  1465. },
  1466. }
  1467. resp, err := svc.PutBucketTagging(params)
  1468. if err != nil {
  1469. // Print the error, cast err to awserr.Error to get the Code and
  1470. // Message from an error.
  1471. fmt.Println(err.Error())
  1472. return
  1473. }
  1474. // Pretty-print the response data.
  1475. fmt.Println(resp)
  1476. }
  1477. func ExampleS3_PutBucketVersioning() {
  1478. sess, err := session.NewSession()
  1479. if err != nil {
  1480. fmt.Println("failed to create session,", err)
  1481. return
  1482. }
  1483. svc := s3.New(sess)
  1484. params := &s3.PutBucketVersioningInput{
  1485. Bucket: aws.String("BucketName"), // Required
  1486. VersioningConfiguration: &s3.VersioningConfiguration{ // Required
  1487. MFADelete: aws.String("MFADelete"),
  1488. Status: aws.String("BucketVersioningStatus"),
  1489. },
  1490. MFA: aws.String("MFA"),
  1491. }
  1492. resp, err := svc.PutBucketVersioning(params)
  1493. if err != nil {
  1494. // Print the error, cast err to awserr.Error to get the Code and
  1495. // Message from an error.
  1496. fmt.Println(err.Error())
  1497. return
  1498. }
  1499. // Pretty-print the response data.
  1500. fmt.Println(resp)
  1501. }
  1502. func ExampleS3_PutBucketWebsite() {
  1503. sess, err := session.NewSession()
  1504. if err != nil {
  1505. fmt.Println("failed to create session,", err)
  1506. return
  1507. }
  1508. svc := s3.New(sess)
  1509. params := &s3.PutBucketWebsiteInput{
  1510. Bucket: aws.String("BucketName"), // Required
  1511. WebsiteConfiguration: &s3.WebsiteConfiguration{ // Required
  1512. ErrorDocument: &s3.ErrorDocument{
  1513. Key: aws.String("ObjectKey"), // Required
  1514. },
  1515. IndexDocument: &s3.IndexDocument{
  1516. Suffix: aws.String("Suffix"), // Required
  1517. },
  1518. RedirectAllRequestsTo: &s3.RedirectAllRequestsTo{
  1519. HostName: aws.String("HostName"), // Required
  1520. Protocol: aws.String("Protocol"),
  1521. },
  1522. RoutingRules: []*s3.RoutingRule{
  1523. { // Required
  1524. Redirect: &s3.Redirect{ // Required
  1525. HostName: aws.String("HostName"),
  1526. HttpRedirectCode: aws.String("HttpRedirectCode"),
  1527. Protocol: aws.String("Protocol"),
  1528. ReplaceKeyPrefixWith: aws.String("ReplaceKeyPrefixWith"),
  1529. ReplaceKeyWith: aws.String("ReplaceKeyWith"),
  1530. },
  1531. Condition: &s3.Condition{
  1532. HttpErrorCodeReturnedEquals: aws.String("HttpErrorCodeReturnedEquals"),
  1533. KeyPrefixEquals: aws.String("KeyPrefixEquals"),
  1534. },
  1535. },
  1536. // More values...
  1537. },
  1538. },
  1539. }
  1540. resp, err := svc.PutBucketWebsite(params)
  1541. if err != nil {
  1542. // Print the error, cast err to awserr.Error to get the Code and
  1543. // Message from an error.
  1544. fmt.Println(err.Error())
  1545. return
  1546. }
  1547. // Pretty-print the response data.
  1548. fmt.Println(resp)
  1549. }
  1550. func ExampleS3_PutObject() {
  1551. sess, err := session.NewSession()
  1552. if err != nil {
  1553. fmt.Println("failed to create session,", err)
  1554. return
  1555. }
  1556. svc := s3.New(sess)
  1557. params := &s3.PutObjectInput{
  1558. Bucket: aws.String("BucketName"), // Required
  1559. Key: aws.String("ObjectKey"), // Required
  1560. ACL: aws.String("ObjectCannedACL"),
  1561. Body: bytes.NewReader([]byte("PAYLOAD")),
  1562. CacheControl: aws.String("CacheControl"),
  1563. ContentDisposition: aws.String("ContentDisposition"),
  1564. ContentEncoding: aws.String("ContentEncoding"),
  1565. ContentLanguage: aws.String("ContentLanguage"),
  1566. ContentLength: aws.Int64(1),
  1567. ContentType: aws.String("ContentType"),
  1568. Expires: aws.Time(time.Now()),
  1569. GrantFullControl: aws.String("GrantFullControl"),
  1570. GrantRead: aws.String("GrantRead"),
  1571. GrantReadACP: aws.String("GrantReadACP"),
  1572. GrantWriteACP: aws.String("GrantWriteACP"),
  1573. Metadata: map[string]*string{
  1574. "Key": aws.String("MetadataValue"), // Required
  1575. // More values...
  1576. },
  1577. RequestPayer: aws.String("RequestPayer"),
  1578. SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
  1579. SSECustomerKey: aws.String("SSECustomerKey"),
  1580. SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
  1581. SSEKMSKeyId: aws.String("SSEKMSKeyId"),
  1582. ServerSideEncryption: aws.String("ServerSideEncryption"),
  1583. StorageClass: aws.String("StorageClass"),
  1584. WebsiteRedirectLocation: aws.String("WebsiteRedirectLocation"),
  1585. }
  1586. resp, err := svc.PutObject(params)
  1587. if err != nil {
  1588. // Print the error, cast err to awserr.Error to get the Code and
  1589. // Message from an error.
  1590. fmt.Println(err.Error())
  1591. return
  1592. }
  1593. // Pretty-print the response data.
  1594. fmt.Println(resp)
  1595. }
  1596. func ExampleS3_PutObjectAcl() {
  1597. sess, err := session.NewSession()
  1598. if err != nil {
  1599. fmt.Println("failed to create session,", err)
  1600. return
  1601. }
  1602. svc := s3.New(sess)
  1603. params := &s3.PutObjectAclInput{
  1604. Bucket: aws.String("BucketName"), // Required
  1605. Key: aws.String("ObjectKey"), // Required
  1606. ACL: aws.String("ObjectCannedACL"),
  1607. AccessControlPolicy: &s3.AccessControlPolicy{
  1608. Grants: []*s3.Grant{
  1609. { // Required
  1610. Grantee: &s3.Grantee{
  1611. Type: aws.String("Type"), // Required
  1612. DisplayName: aws.String("DisplayName"),
  1613. EmailAddress: aws.String("EmailAddress"),
  1614. ID: aws.String("ID"),
  1615. URI: aws.String("URI"),
  1616. },
  1617. Permission: aws.String("Permission"),
  1618. },
  1619. // More values...
  1620. },
  1621. Owner: &s3.Owner{
  1622. DisplayName: aws.String("DisplayName"),
  1623. ID: aws.String("ID"),
  1624. },
  1625. },
  1626. GrantFullControl: aws.String("GrantFullControl"),
  1627. GrantRead: aws.String("GrantRead"),
  1628. GrantReadACP: aws.String("GrantReadACP"),
  1629. GrantWrite: aws.String("GrantWrite"),
  1630. GrantWriteACP: aws.String("GrantWriteACP"),
  1631. RequestPayer: aws.String("RequestPayer"),
  1632. VersionId: aws.String("ObjectVersionId"),
  1633. }
  1634. resp, err := svc.PutObjectAcl(params)
  1635. if err != nil {
  1636. // Print the error, cast err to awserr.Error to get the Code and
  1637. // Message from an error.
  1638. fmt.Println(err.Error())
  1639. return
  1640. }
  1641. // Pretty-print the response data.
  1642. fmt.Println(resp)
  1643. }
  1644. func ExampleS3_RestoreObject() {
  1645. sess, err := session.NewSession()
  1646. if err != nil {
  1647. fmt.Println("failed to create session,", err)
  1648. return
  1649. }
  1650. svc := s3.New(sess)
  1651. params := &s3.RestoreObjectInput{
  1652. Bucket: aws.String("BucketName"), // Required
  1653. Key: aws.String("ObjectKey"), // Required
  1654. RequestPayer: aws.String("RequestPayer"),
  1655. RestoreRequest: &s3.RestoreRequest{
  1656. Days: aws.Int64(1), // Required
  1657. },
  1658. VersionId: aws.String("ObjectVersionId"),
  1659. }
  1660. resp, err := svc.RestoreObject(params)
  1661. if err != nil {
  1662. // Print the error, cast err to awserr.Error to get the Code and
  1663. // Message from an error.
  1664. fmt.Println(err.Error())
  1665. return
  1666. }
  1667. // Pretty-print the response data.
  1668. fmt.Println(resp)
  1669. }
  1670. func ExampleS3_UploadPart() {
  1671. sess, err := session.NewSession()
  1672. if err != nil {
  1673. fmt.Println("failed to create session,", err)
  1674. return
  1675. }
  1676. svc := s3.New(sess)
  1677. params := &s3.UploadPartInput{
  1678. Bucket: aws.String("BucketName"), // Required
  1679. Key: aws.String("ObjectKey"), // Required
  1680. PartNumber: aws.Int64(1), // Required
  1681. UploadId: aws.String("MultipartUploadId"), // Required
  1682. Body: bytes.NewReader([]byte("PAYLOAD")),
  1683. ContentLength: aws.Int64(1),
  1684. RequestPayer: aws.String("RequestPayer"),
  1685. SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
  1686. SSECustomerKey: aws.String("SSECustomerKey"),
  1687. SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
  1688. }
  1689. resp, err := svc.UploadPart(params)
  1690. if err != nil {
  1691. // Print the error, cast err to awserr.Error to get the Code and
  1692. // Message from an error.
  1693. fmt.Println(err.Error())
  1694. return
  1695. }
  1696. // Pretty-print the response data.
  1697. fmt.Println(resp)
  1698. }
  1699. func ExampleS3_UploadPartCopy() {
  1700. sess, err := session.NewSession()
  1701. if err != nil {
  1702. fmt.Println("failed to create session,", err)
  1703. return
  1704. }
  1705. svc := s3.New(sess)
  1706. params := &s3.UploadPartCopyInput{
  1707. Bucket: aws.String("BucketName"), // Required
  1708. CopySource: aws.String("CopySource"), // Required
  1709. Key: aws.String("ObjectKey"), // Required
  1710. PartNumber: aws.Int64(1), // Required
  1711. UploadId: aws.String("MultipartUploadId"), // Required
  1712. CopySourceIfMatch: aws.String("CopySourceIfMatch"),
  1713. CopySourceIfModifiedSince: aws.Time(time.Now()),
  1714. CopySourceIfNoneMatch: aws.String("CopySourceIfNoneMatch"),
  1715. CopySourceIfUnmodifiedSince: aws.Time(time.Now()),
  1716. CopySourceRange: aws.String("CopySourceRange"),
  1717. CopySourceSSECustomerAlgorithm: aws.String("CopySourceSSECustomerAlgorithm"),
  1718. CopySourceSSECustomerKey: aws.String("CopySourceSSECustomerKey"),
  1719. CopySourceSSECustomerKeyMD5: aws.String("CopySourceSSECustomerKeyMD5"),
  1720. RequestPayer: aws.String("RequestPayer"),
  1721. SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
  1722. SSECustomerKey: aws.String("SSECustomerKey"),
  1723. SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
  1724. }
  1725. resp, err := svc.UploadPartCopy(params)
  1726. if err != nil {
  1727. // Print the error, cast err to awserr.Error to get the Code and
  1728. // Message from an error.
  1729. fmt.Println(err.Error())
  1730. return
  1731. }
  1732. // Pretty-print the response data.
  1733. fmt.Println(resp)
  1734. }