| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029 |
- // 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()),
- 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()),
- 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"),
- }
- 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"),
- 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)
- }
|