12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033 |
- // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
- package s3_test
- import (
- "bytes"
- "fmt"
- "time"
- "github.com/aws/aws-sdk-go/aws"
- "github.com/aws/aws-sdk-go/aws/session"
- "github.com/aws/aws-sdk-go/service/s3"
- )
- var _ time.Duration
- var _ bytes.Buffer
- func ExampleS3_AbortMultipartUpload() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.AbortMultipartUploadInput{
- Bucket: aws.String("BucketName"), // Required
- Key: aws.String("ObjectKey"), // Required
- UploadId: aws.String("MultipartUploadId"), // Required
- RequestPayer: aws.String("RequestPayer"),
- }
- resp, err := svc.AbortMultipartUpload(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_CompleteMultipartUpload() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.CompleteMultipartUploadInput{
- Bucket: aws.String("BucketName"), // Required
- Key: aws.String("ObjectKey"), // Required
- UploadId: aws.String("MultipartUploadId"), // Required
- MultipartUpload: &s3.CompletedMultipartUpload{
- Parts: []*s3.CompletedPart{
- { // Required
- ETag: aws.String("ETag"),
- PartNumber: aws.Int64(1),
- },
- // More values...
- },
- },
- RequestPayer: aws.String("RequestPayer"),
- }
- resp, err := svc.CompleteMultipartUpload(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_CopyObject() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.CopyObjectInput{
- Bucket: aws.String("BucketName"), // Required
- CopySource: aws.String("CopySource"), // Required
- Key: aws.String("ObjectKey"), // Required
- ACL: aws.String("ObjectCannedACL"),
- CacheControl: aws.String("CacheControl"),
- ContentDisposition: aws.String("ContentDisposition"),
- ContentEncoding: aws.String("ContentEncoding"),
- ContentLanguage: aws.String("ContentLanguage"),
- ContentType: aws.String("ContentType"),
- CopySourceIfMatch: aws.String("CopySourceIfMatch"),
- CopySourceIfModifiedSince: aws.Time(time.Now()),
- CopySourceIfNoneMatch: aws.String("CopySourceIfNoneMatch"),
- CopySourceIfUnmodifiedSince: aws.Time(time.Now()),
- CopySourceSSECustomerAlgorithm: aws.String("CopySourceSSECustomerAlgorithm"),
- CopySourceSSECustomerKey: aws.String("CopySourceSSECustomerKey"),
- CopySourceSSECustomerKeyMD5: aws.String("CopySourceSSECustomerKeyMD5"),
- Expires: aws.Time(time.Now()),
- GrantFullControl: aws.String("GrantFullControl"),
- GrantRead: aws.String("GrantRead"),
- GrantReadACP: aws.String("GrantReadACP"),
- GrantWriteACP: aws.String("GrantWriteACP"),
- Metadata: map[string]*string{
- "Key": aws.String("MetadataValue"), // Required
- // More values...
- },
- MetadataDirective: aws.String("MetadataDirective"),
- RequestPayer: aws.String("RequestPayer"),
- SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
- SSECustomerKey: aws.String("SSECustomerKey"),
- SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
- SSEKMSKeyId: aws.String("SSEKMSKeyId"),
- ServerSideEncryption: aws.String("ServerSideEncryption"),
- StorageClass: aws.String("StorageClass"),
- WebsiteRedirectLocation: aws.String("WebsiteRedirectLocation"),
- }
- resp, err := svc.CopyObject(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_CreateBucket() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.CreateBucketInput{
- Bucket: aws.String("BucketName"), // Required
- ACL: aws.String("BucketCannedACL"),
- CreateBucketConfiguration: &s3.CreateBucketConfiguration{
- LocationConstraint: aws.String("BucketLocationConstraint"),
- },
- GrantFullControl: aws.String("GrantFullControl"),
- GrantRead: aws.String("GrantRead"),
- GrantReadACP: aws.String("GrantReadACP"),
- GrantWrite: aws.String("GrantWrite"),
- GrantWriteACP: aws.String("GrantWriteACP"),
- }
- resp, err := svc.CreateBucket(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_CreateMultipartUpload() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.CreateMultipartUploadInput{
- Bucket: aws.String("BucketName"), // Required
- Key: aws.String("ObjectKey"), // Required
- ACL: aws.String("ObjectCannedACL"),
- CacheControl: aws.String("CacheControl"),
- ContentDisposition: aws.String("ContentDisposition"),
- ContentEncoding: aws.String("ContentEncoding"),
- ContentLanguage: aws.String("ContentLanguage"),
- ContentType: aws.String("ContentType"),
- Expires: aws.Time(time.Now()),
- GrantFullControl: aws.String("GrantFullControl"),
- GrantRead: aws.String("GrantRead"),
- GrantReadACP: aws.String("GrantReadACP"),
- GrantWriteACP: aws.String("GrantWriteACP"),
- Metadata: map[string]*string{
- "Key": aws.String("MetadataValue"), // Required
- // More values...
- },
- RequestPayer: aws.String("RequestPayer"),
- SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
- SSECustomerKey: aws.String("SSECustomerKey"),
- SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
- SSEKMSKeyId: aws.String("SSEKMSKeyId"),
- ServerSideEncryption: aws.String("ServerSideEncryption"),
- StorageClass: aws.String("StorageClass"),
- WebsiteRedirectLocation: aws.String("WebsiteRedirectLocation"),
- }
- resp, err := svc.CreateMultipartUpload(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_DeleteBucket() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.DeleteBucketInput{
- Bucket: aws.String("BucketName"), // Required
- }
- resp, err := svc.DeleteBucket(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_DeleteBucketCors() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.DeleteBucketCorsInput{
- Bucket: aws.String("BucketName"), // Required
- }
- resp, err := svc.DeleteBucketCors(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_DeleteBucketLifecycle() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.DeleteBucketLifecycleInput{
- Bucket: aws.String("BucketName"), // Required
- }
- resp, err := svc.DeleteBucketLifecycle(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_DeleteBucketPolicy() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.DeleteBucketPolicyInput{
- Bucket: aws.String("BucketName"), // Required
- }
- resp, err := svc.DeleteBucketPolicy(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_DeleteBucketReplication() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.DeleteBucketReplicationInput{
- Bucket: aws.String("BucketName"), // Required
- }
- resp, err := svc.DeleteBucketReplication(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_DeleteBucketTagging() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.DeleteBucketTaggingInput{
- Bucket: aws.String("BucketName"), // Required
- }
- resp, err := svc.DeleteBucketTagging(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_DeleteBucketWebsite() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.DeleteBucketWebsiteInput{
- Bucket: aws.String("BucketName"), // Required
- }
- resp, err := svc.DeleteBucketWebsite(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_DeleteObject() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.DeleteObjectInput{
- Bucket: aws.String("BucketName"), // Required
- Key: aws.String("ObjectKey"), // Required
- MFA: aws.String("MFA"),
- RequestPayer: aws.String("RequestPayer"),
- VersionId: aws.String("ObjectVersionId"),
- }
- resp, err := svc.DeleteObject(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_DeleteObjects() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.DeleteObjectsInput{
- Bucket: aws.String("BucketName"), // Required
- Delete: &s3.Delete{ // Required
- Objects: []*s3.ObjectIdentifier{ // Required
- { // Required
- Key: aws.String("ObjectKey"), // Required
- VersionId: aws.String("ObjectVersionId"),
- },
- // More values...
- },
- Quiet: aws.Bool(true),
- },
- MFA: aws.String("MFA"),
- RequestPayer: aws.String("RequestPayer"),
- }
- resp, err := svc.DeleteObjects(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_GetBucketAccelerateConfiguration() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.GetBucketAccelerateConfigurationInput{
- Bucket: aws.String("BucketName"), // Required
- }
- resp, err := svc.GetBucketAccelerateConfiguration(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_GetBucketAcl() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.GetBucketAclInput{
- Bucket: aws.String("BucketName"), // Required
- }
- resp, err := svc.GetBucketAcl(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_GetBucketCors() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.GetBucketCorsInput{
- Bucket: aws.String("BucketName"), // Required
- }
- resp, err := svc.GetBucketCors(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_GetBucketLifecycle() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.GetBucketLifecycleInput{
- Bucket: aws.String("BucketName"), // Required
- }
- resp, err := svc.GetBucketLifecycle(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_GetBucketLifecycleConfiguration() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.GetBucketLifecycleConfigurationInput{
- Bucket: aws.String("BucketName"), // Required
- }
- resp, err := svc.GetBucketLifecycleConfiguration(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_GetBucketLocation() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.GetBucketLocationInput{
- Bucket: aws.String("BucketName"), // Required
- }
- resp, err := svc.GetBucketLocation(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_GetBucketLogging() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.GetBucketLoggingInput{
- Bucket: aws.String("BucketName"), // Required
- }
- resp, err := svc.GetBucketLogging(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_GetBucketNotification() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.GetBucketNotificationConfigurationRequest{
- Bucket: aws.String("BucketName"), // Required
- }
- resp, err := svc.GetBucketNotification(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_GetBucketNotificationConfiguration() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.GetBucketNotificationConfigurationRequest{
- Bucket: aws.String("BucketName"), // Required
- }
- resp, err := svc.GetBucketNotificationConfiguration(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_GetBucketPolicy() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.GetBucketPolicyInput{
- Bucket: aws.String("BucketName"), // Required
- }
- resp, err := svc.GetBucketPolicy(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_GetBucketReplication() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.GetBucketReplicationInput{
- Bucket: aws.String("BucketName"), // Required
- }
- resp, err := svc.GetBucketReplication(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_GetBucketRequestPayment() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.GetBucketRequestPaymentInput{
- Bucket: aws.String("BucketName"), // Required
- }
- resp, err := svc.GetBucketRequestPayment(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_GetBucketTagging() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.GetBucketTaggingInput{
- Bucket: aws.String("BucketName"), // Required
- }
- resp, err := svc.GetBucketTagging(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_GetBucketVersioning() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.GetBucketVersioningInput{
- Bucket: aws.String("BucketName"), // Required
- }
- resp, err := svc.GetBucketVersioning(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_GetBucketWebsite() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.GetBucketWebsiteInput{
- Bucket: aws.String("BucketName"), // Required
- }
- resp, err := svc.GetBucketWebsite(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_GetObject() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.GetObjectInput{
- Bucket: aws.String("BucketName"), // Required
- Key: aws.String("ObjectKey"), // Required
- IfMatch: aws.String("IfMatch"),
- IfModifiedSince: aws.Time(time.Now()),
- IfNoneMatch: aws.String("IfNoneMatch"),
- IfUnmodifiedSince: aws.Time(time.Now()),
- PartNumber: aws.Int64(1),
- Range: aws.String("Range"),
- RequestPayer: aws.String("RequestPayer"),
- ResponseCacheControl: aws.String("ResponseCacheControl"),
- ResponseContentDisposition: aws.String("ResponseContentDisposition"),
- ResponseContentEncoding: aws.String("ResponseContentEncoding"),
- ResponseContentLanguage: aws.String("ResponseContentLanguage"),
- ResponseContentType: aws.String("ResponseContentType"),
- ResponseExpires: aws.Time(time.Now()),
- SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
- SSECustomerKey: aws.String("SSECustomerKey"),
- SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
- VersionId: aws.String("ObjectVersionId"),
- }
- resp, err := svc.GetObject(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_GetObjectAcl() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.GetObjectAclInput{
- Bucket: aws.String("BucketName"), // Required
- Key: aws.String("ObjectKey"), // Required
- RequestPayer: aws.String("RequestPayer"),
- VersionId: aws.String("ObjectVersionId"),
- }
- resp, err := svc.GetObjectAcl(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_GetObjectTorrent() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.GetObjectTorrentInput{
- Bucket: aws.String("BucketName"), // Required
- Key: aws.String("ObjectKey"), // Required
- RequestPayer: aws.String("RequestPayer"),
- }
- resp, err := svc.GetObjectTorrent(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_HeadBucket() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.HeadBucketInput{
- Bucket: aws.String("BucketName"), // Required
- }
- resp, err := svc.HeadBucket(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_HeadObject() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.HeadObjectInput{
- Bucket: aws.String("BucketName"), // Required
- Key: aws.String("ObjectKey"), // Required
- IfMatch: aws.String("IfMatch"),
- IfModifiedSince: aws.Time(time.Now()),
- IfNoneMatch: aws.String("IfNoneMatch"),
- IfUnmodifiedSince: aws.Time(time.Now()),
- PartNumber: aws.Int64(1),
- Range: aws.String("Range"),
- RequestPayer: aws.String("RequestPayer"),
- SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
- SSECustomerKey: aws.String("SSECustomerKey"),
- SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
- VersionId: aws.String("ObjectVersionId"),
- }
- resp, err := svc.HeadObject(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_ListBuckets() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- var params *s3.ListBucketsInput
- resp, err := svc.ListBuckets(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_ListMultipartUploads() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.ListMultipartUploadsInput{
- Bucket: aws.String("BucketName"), // Required
- Delimiter: aws.String("Delimiter"),
- EncodingType: aws.String("EncodingType"),
- KeyMarker: aws.String("KeyMarker"),
- MaxUploads: aws.Int64(1),
- Prefix: aws.String("Prefix"),
- UploadIdMarker: aws.String("UploadIdMarker"),
- }
- resp, err := svc.ListMultipartUploads(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_ListObjectVersions() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.ListObjectVersionsInput{
- Bucket: aws.String("BucketName"), // Required
- Delimiter: aws.String("Delimiter"),
- EncodingType: aws.String("EncodingType"),
- KeyMarker: aws.String("KeyMarker"),
- MaxKeys: aws.Int64(1),
- Prefix: aws.String("Prefix"),
- VersionIdMarker: aws.String("VersionIdMarker"),
- }
- resp, err := svc.ListObjectVersions(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_ListObjects() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.ListObjectsInput{
- Bucket: aws.String("BucketName"), // Required
- Delimiter: aws.String("Delimiter"),
- EncodingType: aws.String("EncodingType"),
- Marker: aws.String("Marker"),
- MaxKeys: aws.Int64(1),
- Prefix: aws.String("Prefix"),
- RequestPayer: aws.String("RequestPayer"),
- }
- resp, err := svc.ListObjects(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_ListObjectsV2() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.ListObjectsV2Input{
- Bucket: aws.String("BucketName"), // Required
- ContinuationToken: aws.String("Token"),
- Delimiter: aws.String("Delimiter"),
- EncodingType: aws.String("EncodingType"),
- FetchOwner: aws.Bool(true),
- MaxKeys: aws.Int64(1),
- Prefix: aws.String("Prefix"),
- RequestPayer: aws.String("RequestPayer"),
- StartAfter: aws.String("StartAfter"),
- }
- resp, err := svc.ListObjectsV2(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_ListParts() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.ListPartsInput{
- Bucket: aws.String("BucketName"), // Required
- Key: aws.String("ObjectKey"), // Required
- UploadId: aws.String("MultipartUploadId"), // Required
- MaxParts: aws.Int64(1),
- PartNumberMarker: aws.Int64(1),
- RequestPayer: aws.String("RequestPayer"),
- }
- resp, err := svc.ListParts(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_PutBucketAccelerateConfiguration() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.PutBucketAccelerateConfigurationInput{
- AccelerateConfiguration: &s3.AccelerateConfiguration{ // Required
- Status: aws.String("BucketAccelerateStatus"),
- },
- Bucket: aws.String("BucketName"), // Required
- }
- resp, err := svc.PutBucketAccelerateConfiguration(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_PutBucketAcl() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.PutBucketAclInput{
- Bucket: aws.String("BucketName"), // Required
- ACL: aws.String("BucketCannedACL"),
- AccessControlPolicy: &s3.AccessControlPolicy{
- Grants: []*s3.Grant{
- { // Required
- Grantee: &s3.Grantee{
- Type: aws.String("Type"), // Required
- DisplayName: aws.String("DisplayName"),
- EmailAddress: aws.String("EmailAddress"),
- ID: aws.String("ID"),
- URI: aws.String("URI"),
- },
- Permission: aws.String("Permission"),
- },
- // More values...
- },
- Owner: &s3.Owner{
- DisplayName: aws.String("DisplayName"),
- ID: aws.String("ID"),
- },
- },
- GrantFullControl: aws.String("GrantFullControl"),
- GrantRead: aws.String("GrantRead"),
- GrantReadACP: aws.String("GrantReadACP"),
- GrantWrite: aws.String("GrantWrite"),
- GrantWriteACP: aws.String("GrantWriteACP"),
- }
- resp, err := svc.PutBucketAcl(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_PutBucketCors() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.PutBucketCorsInput{
- Bucket: aws.String("BucketName"), // Required
- CORSConfiguration: &s3.CORSConfiguration{ // Required
- CORSRules: []*s3.CORSRule{ // Required
- { // Required
- AllowedMethods: []*string{ // Required
- aws.String("AllowedMethod"), // Required
- // More values...
- },
- AllowedOrigins: []*string{ // Required
- aws.String("AllowedOrigin"), // Required
- // More values...
- },
- AllowedHeaders: []*string{
- aws.String("AllowedHeader"), // Required
- // More values...
- },
- ExposeHeaders: []*string{
- aws.String("ExposeHeader"), // Required
- // More values...
- },
- MaxAgeSeconds: aws.Int64(1),
- },
- // More values...
- },
- },
- }
- resp, err := svc.PutBucketCors(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_PutBucketLifecycle() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.PutBucketLifecycleInput{
- Bucket: aws.String("BucketName"), // Required
- LifecycleConfiguration: &s3.LifecycleConfiguration{
- Rules: []*s3.Rule{ // Required
- { // Required
- Prefix: aws.String("Prefix"), // Required
- Status: aws.String("ExpirationStatus"), // Required
- AbortIncompleteMultipartUpload: &s3.AbortIncompleteMultipartUpload{
- DaysAfterInitiation: aws.Int64(1),
- },
- Expiration: &s3.LifecycleExpiration{
- Date: aws.Time(time.Now()),
- Days: aws.Int64(1),
- ExpiredObjectDeleteMarker: aws.Bool(true),
- },
- ID: aws.String("ID"),
- NoncurrentVersionExpiration: &s3.NoncurrentVersionExpiration{
- NoncurrentDays: aws.Int64(1),
- },
- NoncurrentVersionTransition: &s3.NoncurrentVersionTransition{
- NoncurrentDays: aws.Int64(1),
- StorageClass: aws.String("TransitionStorageClass"),
- },
- Transition: &s3.Transition{
- Date: aws.Time(time.Now()),
- Days: aws.Int64(1),
- StorageClass: aws.String("TransitionStorageClass"),
- },
- },
- // More values...
- },
- },
- }
- resp, err := svc.PutBucketLifecycle(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_PutBucketLifecycleConfiguration() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.PutBucketLifecycleConfigurationInput{
- Bucket: aws.String("BucketName"), // Required
- LifecycleConfiguration: &s3.BucketLifecycleConfiguration{
- Rules: []*s3.LifecycleRule{ // Required
- { // Required
- Prefix: aws.String("Prefix"), // Required
- Status: aws.String("ExpirationStatus"), // Required
- AbortIncompleteMultipartUpload: &s3.AbortIncompleteMultipartUpload{
- DaysAfterInitiation: aws.Int64(1),
- },
- Expiration: &s3.LifecycleExpiration{
- Date: aws.Time(time.Now()),
- Days: aws.Int64(1),
- ExpiredObjectDeleteMarker: aws.Bool(true),
- },
- ID: aws.String("ID"),
- NoncurrentVersionExpiration: &s3.NoncurrentVersionExpiration{
- NoncurrentDays: aws.Int64(1),
- },
- NoncurrentVersionTransitions: []*s3.NoncurrentVersionTransition{
- { // Required
- NoncurrentDays: aws.Int64(1),
- StorageClass: aws.String("TransitionStorageClass"),
- },
- // More values...
- },
- Transitions: []*s3.Transition{
- { // Required
- Date: aws.Time(time.Now()),
- Days: aws.Int64(1),
- StorageClass: aws.String("TransitionStorageClass"),
- },
- // More values...
- },
- },
- // More values...
- },
- },
- }
- resp, err := svc.PutBucketLifecycleConfiguration(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_PutBucketLogging() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.PutBucketLoggingInput{
- Bucket: aws.String("BucketName"), // Required
- BucketLoggingStatus: &s3.BucketLoggingStatus{ // Required
- LoggingEnabled: &s3.LoggingEnabled{
- TargetBucket: aws.String("TargetBucket"),
- TargetGrants: []*s3.TargetGrant{
- { // Required
- Grantee: &s3.Grantee{
- Type: aws.String("Type"), // Required
- DisplayName: aws.String("DisplayName"),
- EmailAddress: aws.String("EmailAddress"),
- ID: aws.String("ID"),
- URI: aws.String("URI"),
- },
- Permission: aws.String("BucketLogsPermission"),
- },
- // More values...
- },
- TargetPrefix: aws.String("TargetPrefix"),
- },
- },
- }
- resp, err := svc.PutBucketLogging(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_PutBucketNotification() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.PutBucketNotificationInput{
- Bucket: aws.String("BucketName"), // Required
- NotificationConfiguration: &s3.NotificationConfigurationDeprecated{ // Required
- CloudFunctionConfiguration: &s3.CloudFunctionConfiguration{
- CloudFunction: aws.String("CloudFunction"),
- Event: aws.String("Event"),
- Events: []*string{
- aws.String("Event"), // Required
- // More values...
- },
- Id: aws.String("NotificationId"),
- InvocationRole: aws.String("CloudFunctionInvocationRole"),
- },
- QueueConfiguration: &s3.QueueConfigurationDeprecated{
- Event: aws.String("Event"),
- Events: []*string{
- aws.String("Event"), // Required
- // More values...
- },
- Id: aws.String("NotificationId"),
- Queue: aws.String("QueueArn"),
- },
- TopicConfiguration: &s3.TopicConfigurationDeprecated{
- Event: aws.String("Event"),
- Events: []*string{
- aws.String("Event"), // Required
- // More values...
- },
- Id: aws.String("NotificationId"),
- Topic: aws.String("TopicArn"),
- },
- },
- }
- resp, err := svc.PutBucketNotification(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_PutBucketNotificationConfiguration() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.PutBucketNotificationConfigurationInput{
- Bucket: aws.String("BucketName"), // Required
- NotificationConfiguration: &s3.NotificationConfiguration{ // Required
- LambdaFunctionConfigurations: []*s3.LambdaFunctionConfiguration{
- { // Required
- Events: []*string{ // Required
- aws.String("Event"), // Required
- // More values...
- },
- LambdaFunctionArn: aws.String("LambdaFunctionArn"), // Required
- Filter: &s3.NotificationConfigurationFilter{
- Key: &s3.KeyFilter{
- FilterRules: []*s3.FilterRule{
- { // Required
- Name: aws.String("FilterRuleName"),
- Value: aws.String("FilterRuleValue"),
- },
- // More values...
- },
- },
- },
- Id: aws.String("NotificationId"),
- },
- // More values...
- },
- QueueConfigurations: []*s3.QueueConfiguration{
- { // Required
- Events: []*string{ // Required
- aws.String("Event"), // Required
- // More values...
- },
- QueueArn: aws.String("QueueArn"), // Required
- Filter: &s3.NotificationConfigurationFilter{
- Key: &s3.KeyFilter{
- FilterRules: []*s3.FilterRule{
- { // Required
- Name: aws.String("FilterRuleName"),
- Value: aws.String("FilterRuleValue"),
- },
- // More values...
- },
- },
- },
- Id: aws.String("NotificationId"),
- },
- // More values...
- },
- TopicConfigurations: []*s3.TopicConfiguration{
- { // Required
- Events: []*string{ // Required
- aws.String("Event"), // Required
- // More values...
- },
- TopicArn: aws.String("TopicArn"), // Required
- Filter: &s3.NotificationConfigurationFilter{
- Key: &s3.KeyFilter{
- FilterRules: []*s3.FilterRule{
- { // Required
- Name: aws.String("FilterRuleName"),
- Value: aws.String("FilterRuleValue"),
- },
- // More values...
- },
- },
- },
- Id: aws.String("NotificationId"),
- },
- // More values...
- },
- },
- }
- resp, err := svc.PutBucketNotificationConfiguration(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_PutBucketPolicy() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.PutBucketPolicyInput{
- Bucket: aws.String("BucketName"), // Required
- Policy: aws.String("Policy"), // Required
- }
- resp, err := svc.PutBucketPolicy(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_PutBucketReplication() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.PutBucketReplicationInput{
- Bucket: aws.String("BucketName"), // Required
- ReplicationConfiguration: &s3.ReplicationConfiguration{ // Required
- Role: aws.String("Role"), // Required
- Rules: []*s3.ReplicationRule{ // Required
- { // Required
- Destination: &s3.Destination{ // Required
- Bucket: aws.String("BucketName"), // Required
- StorageClass: aws.String("StorageClass"),
- },
- Prefix: aws.String("Prefix"), // Required
- Status: aws.String("ReplicationRuleStatus"), // Required
- ID: aws.String("ID"),
- },
- // More values...
- },
- },
- }
- resp, err := svc.PutBucketReplication(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_PutBucketRequestPayment() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.PutBucketRequestPaymentInput{
- Bucket: aws.String("BucketName"), // Required
- RequestPaymentConfiguration: &s3.RequestPaymentConfiguration{ // Required
- Payer: aws.String("Payer"), // Required
- },
- }
- resp, err := svc.PutBucketRequestPayment(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_PutBucketTagging() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.PutBucketTaggingInput{
- Bucket: aws.String("BucketName"), // Required
- Tagging: &s3.Tagging{ // Required
- TagSet: []*s3.Tag{ // Required
- { // Required
- Key: aws.String("ObjectKey"), // Required
- Value: aws.String("Value"), // Required
- },
- // More values...
- },
- },
- }
- resp, err := svc.PutBucketTagging(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_PutBucketVersioning() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.PutBucketVersioningInput{
- Bucket: aws.String("BucketName"), // Required
- VersioningConfiguration: &s3.VersioningConfiguration{ // Required
- MFADelete: aws.String("MFADelete"),
- Status: aws.String("BucketVersioningStatus"),
- },
- MFA: aws.String("MFA"),
- }
- resp, err := svc.PutBucketVersioning(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_PutBucketWebsite() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.PutBucketWebsiteInput{
- Bucket: aws.String("BucketName"), // Required
- WebsiteConfiguration: &s3.WebsiteConfiguration{ // Required
- ErrorDocument: &s3.ErrorDocument{
- Key: aws.String("ObjectKey"), // Required
- },
- IndexDocument: &s3.IndexDocument{
- Suffix: aws.String("Suffix"), // Required
- },
- RedirectAllRequestsTo: &s3.RedirectAllRequestsTo{
- HostName: aws.String("HostName"), // Required
- Protocol: aws.String("Protocol"),
- },
- RoutingRules: []*s3.RoutingRule{
- { // Required
- Redirect: &s3.Redirect{ // Required
- HostName: aws.String("HostName"),
- HttpRedirectCode: aws.String("HttpRedirectCode"),
- Protocol: aws.String("Protocol"),
- ReplaceKeyPrefixWith: aws.String("ReplaceKeyPrefixWith"),
- ReplaceKeyWith: aws.String("ReplaceKeyWith"),
- },
- Condition: &s3.Condition{
- HttpErrorCodeReturnedEquals: aws.String("HttpErrorCodeReturnedEquals"),
- KeyPrefixEquals: aws.String("KeyPrefixEquals"),
- },
- },
- // More values...
- },
- },
- }
- resp, err := svc.PutBucketWebsite(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_PutObject() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.PutObjectInput{
- Bucket: aws.String("BucketName"), // Required
- Key: aws.String("ObjectKey"), // Required
- ACL: aws.String("ObjectCannedACL"),
- Body: bytes.NewReader([]byte("PAYLOAD")),
- CacheControl: aws.String("CacheControl"),
- ContentDisposition: aws.String("ContentDisposition"),
- ContentEncoding: aws.String("ContentEncoding"),
- ContentLanguage: aws.String("ContentLanguage"),
- ContentLength: aws.Int64(1),
- ContentType: aws.String("ContentType"),
- Expires: aws.Time(time.Now()),
- GrantFullControl: aws.String("GrantFullControl"),
- GrantRead: aws.String("GrantRead"),
- GrantReadACP: aws.String("GrantReadACP"),
- GrantWriteACP: aws.String("GrantWriteACP"),
- Metadata: map[string]*string{
- "Key": aws.String("MetadataValue"), // Required
- // More values...
- },
- RequestPayer: aws.String("RequestPayer"),
- SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
- SSECustomerKey: aws.String("SSECustomerKey"),
- SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
- SSEKMSKeyId: aws.String("SSEKMSKeyId"),
- ServerSideEncryption: aws.String("ServerSideEncryption"),
- StorageClass: aws.String("StorageClass"),
- WebsiteRedirectLocation: aws.String("WebsiteRedirectLocation"),
- }
- resp, err := svc.PutObject(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_PutObjectAcl() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.PutObjectAclInput{
- Bucket: aws.String("BucketName"), // Required
- Key: aws.String("ObjectKey"), // Required
- ACL: aws.String("ObjectCannedACL"),
- AccessControlPolicy: &s3.AccessControlPolicy{
- Grants: []*s3.Grant{
- { // Required
- Grantee: &s3.Grantee{
- Type: aws.String("Type"), // Required
- DisplayName: aws.String("DisplayName"),
- EmailAddress: aws.String("EmailAddress"),
- ID: aws.String("ID"),
- URI: aws.String("URI"),
- },
- Permission: aws.String("Permission"),
- },
- // More values...
- },
- Owner: &s3.Owner{
- DisplayName: aws.String("DisplayName"),
- ID: aws.String("ID"),
- },
- },
- GrantFullControl: aws.String("GrantFullControl"),
- GrantRead: aws.String("GrantRead"),
- GrantReadACP: aws.String("GrantReadACP"),
- GrantWrite: aws.String("GrantWrite"),
- GrantWriteACP: aws.String("GrantWriteACP"),
- RequestPayer: aws.String("RequestPayer"),
- VersionId: aws.String("ObjectVersionId"),
- }
- resp, err := svc.PutObjectAcl(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_RestoreObject() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.RestoreObjectInput{
- Bucket: aws.String("BucketName"), // Required
- Key: aws.String("ObjectKey"), // Required
- RequestPayer: aws.String("RequestPayer"),
- RestoreRequest: &s3.RestoreRequest{
- Days: aws.Int64(1), // Required
- },
- VersionId: aws.String("ObjectVersionId"),
- }
- resp, err := svc.RestoreObject(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_UploadPart() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.UploadPartInput{
- Bucket: aws.String("BucketName"), // Required
- Key: aws.String("ObjectKey"), // Required
- PartNumber: aws.Int64(1), // Required
- UploadId: aws.String("MultipartUploadId"), // Required
- Body: bytes.NewReader([]byte("PAYLOAD")),
- ContentLength: aws.Int64(1),
- RequestPayer: aws.String("RequestPayer"),
- SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
- SSECustomerKey: aws.String("SSECustomerKey"),
- SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
- }
- resp, err := svc.UploadPart(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
- func ExampleS3_UploadPartCopy() {
- sess, err := session.NewSession()
- if err != nil {
- fmt.Println("failed to create session,", err)
- return
- }
- svc := s3.New(sess)
- params := &s3.UploadPartCopyInput{
- Bucket: aws.String("BucketName"), // Required
- CopySource: aws.String("CopySource"), // Required
- Key: aws.String("ObjectKey"), // Required
- PartNumber: aws.Int64(1), // Required
- UploadId: aws.String("MultipartUploadId"), // Required
- CopySourceIfMatch: aws.String("CopySourceIfMatch"),
- CopySourceIfModifiedSince: aws.Time(time.Now()),
- CopySourceIfNoneMatch: aws.String("CopySourceIfNoneMatch"),
- CopySourceIfUnmodifiedSince: aws.Time(time.Now()),
- CopySourceRange: aws.String("CopySourceRange"),
- CopySourceSSECustomerAlgorithm: aws.String("CopySourceSSECustomerAlgorithm"),
- CopySourceSSECustomerKey: aws.String("CopySourceSSECustomerKey"),
- CopySourceSSECustomerKeyMD5: aws.String("CopySourceSSECustomerKeyMD5"),
- RequestPayer: aws.String("RequestPayer"),
- SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
- SSECustomerKey: aws.String("SSECustomerKey"),
- SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
- }
- resp, err := svc.UploadPartCopy(params)
- if err != nil {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- return
- }
- // Pretty-print the response data.
- fmt.Println(resp)
- }
|