S3 Tags Instructions
Introduction
Example
Uploading a file and adding tags
func ExampleS3_PutObject() {
svc := s3.New(session.New())
input := &s3.PutObjectInput{
Body: aws.ReadSeekCloser(strings.NewReader("filetoupload")),
Bucket: aws.String("examplebucket"),
Key: aws.String("exampleobject"),
Tagging: aws.String("key1=value1&key2=value2"),
}
result, err := svc.PutObject(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}Adding tags to existing files
Requesting the corresponding tag through the bucket and filename
Field descriptions
Last updated