123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527 |
- // 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/service/s3"
- )
- var _ time.Duration
- var _ bytes.Buffer
- func ExampleS3_AbortMultipartUpload() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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_GetBucketAcl() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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_GetBucketLocation() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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_ListParts() {
- svc := s3.New(nil)
- 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_PutBucketAcl() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- params := &s3.PutBucketCorsInput{
- Bucket: aws.String("BucketName"), // Required
- CORSConfiguration: &s3.CORSConfiguration{
- CORSRules: []*s3.CORSRule{
- { // Required
- AllowedHeaders: []*string{
- aws.String("AllowedHeader"), // Required
- // More values...
- },
- AllowedMethods: []*string{
- aws.String("AllowedMethod"), // Required
- // More values...
- },
- AllowedOrigins: []*string{
- aws.String("AllowedOrigin"), // 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() {
- svc := s3.New(nil)
- params := &s3.PutBucketLifecycleInput{
- Bucket: aws.String("BucketName"), // Required
- LifecycleConfiguration: &s3.LifecycleConfiguration{
- Rules: []*s3.LifecycleRule{ // Required
- { // Required
- Prefix: aws.String("Prefix"), // Required
- Status: aws.String("ExpirationStatus"), // Required
- Expiration: &s3.LifecycleExpiration{
- Date: aws.Time(time.Now()),
- Days: aws.Int64(1),
- },
- 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_PutBucketLogging() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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
- },
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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"),
- }
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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() {
- svc := s3.New(nil)
- 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)
- }
|