diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-10-02 22:21:51 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-10-02 22:21:51 -0700 |
| commit | f781cce500aabacb4e33abaca3e09d9bb8abf522 (patch) | |
| tree | 6aa69dc8dc73ccbccbc9689bcbb5920b1364bc94 /test | |
| parent | 9ab98fa912814686b3035a97b5173c1628fbc0fc (diff) | |
| download | seaweedfs-f781cce500aabacb4e33abaca3e09d9bb8abf522.tar.xz seaweedfs-f781cce500aabacb4e33abaca3e09d9bb8abf522.zip | |
s3: support object tagging
* GetObjectTagging
* PutObjectTagging
* DeleteObjectTagging
Diffstat (limited to 'test')
| -rw-r--r-- | test/s3/basic/object_tagging_test.go | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/test/s3/basic/object_tagging_test.go b/test/s3/basic/object_tagging_test.go new file mode 100644 index 000000000..2b9b7e5aa --- /dev/null +++ b/test/s3/basic/object_tagging_test.go @@ -0,0 +1,82 @@ +package basic + +import ( + "fmt" + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/service/s3" + "testing" +) + +func TestObjectTagging(t *testing.T) { + + input := &s3.PutObjectInput{ + Bucket: aws.String("theBucket"), + Key: aws.String("testDir/testObject"), + } + + svc.PutObject(input) + + printTags() + + setTags() + + printTags() + + clearTags() + + printTags() + +} + +func printTags() { + response, err := svc.GetObjectTagging( + &s3.GetObjectTaggingInput{ + Bucket: aws.String("theBucket"), + Key: aws.String("testDir/testObject"), + }) + + fmt.Println("printTags") + if err != nil { + fmt.Println(err.Error()) + } + + fmt.Println(response.TagSet) +} + +func setTags() { + + response, err := svc.PutObjectTagging(&s3.PutObjectTaggingInput{ + Bucket: aws.String("theBucket"), + Key: aws.String("testDir/testObject"), + Tagging: &s3.Tagging{ + TagSet: []*s3.Tag{ + { + Key: aws.String("kye2"), + Value: aws.String("value2"), + }, + }, + }, + }) + + fmt.Println("setTags") + if err != nil { + fmt.Println(err.Error()) + } + + fmt.Println(response.String()) +} + +func clearTags() { + + response, err := svc.DeleteObjectTagging(&s3.DeleteObjectTaggingInput{ + Bucket: aws.String("theBucket"), + Key: aws.String("testDir/testObject"), + }) + + fmt.Println("clearTags") + if err != nil { + fmt.Println(err.Error()) + } + + fmt.Println(response.String()) +} |
