简体   繁体   中英

Apply multiple tags to an object during uploading via aws cli

What's the correct syntax to upload an object with multiple tags? Following command with 1 tag works fine:

aws s3api put-object --bucket mybucket --key something/obj.txt --body obj.txt --tagging "mykeyname1=myvalue1"

But following command with multiple tags generates error:

aws s3api put-object --bucket mybucket --key something/obj.txt --body obj.txt --tagging "mykeyname1=myvalue1, mykeyname2=myvalue2"

Error

An error occurred (InvalidArgument) when calling the PutObject operation: The header 'x-amz-tagging' shall be encoded as UTF-8 then URLEncoded URL query parameters without tag name duplicates

Unfortunately the documentation is not the best in this case. You can have multiple tags using the following format: key1=value1&key2=value2

For example:

aws s3api put-object --bucket mybucket --key something/obj.txt --body obj.txt --tagging 'mykeyname1=myvalue1&mykeyname2=myvalue2'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM