Unable to set metadata on S3 objects
Setting metadata when putting a new object with the low-level s3api command, fails. Trying to do so using the shorthand syntax results in:
'StringParameter' object has no attribute 'enum'
and trying to use the JSON syntax gives:
AttributeError: 'dict' object has no attribute 'strip'
This has been fixed in the latest release.
I'm using aws-cli/1.2.4 Python/2.7.3 Linux/2.6.18-308.1.1.el5xen
and
$ aws s3api copy-object \
--copy-source bucket/logo.svg \
--metadata "Content-Type=image/svg+xml" \
--bucket bucket \
--key logo.svg
'StringParameter' object has no attribute 'enum'
$ aws s3api copy-object \
--copy-source bucket/logo.svg \
--metadata '{"Content-Type":"image/svg+xml"}' \
--bucket bucket \
--key logo.svg
'dict' object has no attribute 'strip'
?
There is a specific option for setting content-type, so I would use this:
aws s3api copy-object --content-type "image/xvg+xml"
As for the metadata issue, there does seem to be an issue there. Looking into it now. Thanks for reporting.
I have just tried version 1.2.13 and in this version it still does not work.
I can confirm that this issue still exists as well in 1.2.13. If I try to upload with metadata in the shorthand form, I get this:
aws s3api put-object --acl private --bucket some-bucket --key some-key --body some-object.sh --metadata sha256sum=4c8b8f62b3c7537aebac8587ae006698124a6f9db85e670e4ef8f056ae89e243
'OrderedDict' object has no attribute 'strip'
Or if I try the JSON form:
aws s3api put-object --acl private --bucket og-deployments --key s3deploy.sh --body s3deploy.sh --metadata '{"sha256sum":"4c8b8f62b3c7537aebac8587ae006698124a6f9db85e670e4ef8f056ae89e243"}'
'OrderedDict' object has no attribute 'strip'
@tader, @garnaat 's switch-based method works, and this also handles, e.g. --content-encoding, etc. as you would normally set in --metadata.
I also get error using --metadata switch (ordereddict...).
Seeing this with pip-installed 1.3.2.
% aws s3api put-object --acl public-read --metadata x-amz-meta-runtime=45:56 --body foo.mp3 --bucket media.example.com --key foo.mp3
'OrderedDict' object has no attribute 'strip'
Is there any way to do this with 'aws s3 cp'? My scenario is a bit difficult. I'd like to use 's3api put-object' but it doesn't handle multi-part for large file upload (> 1TB). As a result I need to use 's3 cp', but that doesn't appear to have a way to insert metadata.
A second question -- I'd also like to insert multiple key-value pairs. Do you specify these in any particular list form using aws-cli?
Great product so far -- thanks for the development effort!
+1 for @rmatt to add the ability to insert meta data with aws s3 cp. We need this, too. What is the status on this?
@rmatt @tim-kos Given that the OP was regarding the s3api subcommand, it might be best to open a new issue if you're looking to add support for arbitrary metadata to s3 cp.
The way I've done this in the past is to s3 cp the file to a staging bucket/key and then s3api copy-object it from there to where it should actually go with the correct metadata, and then s3 rm the temporary object. It's a little more work than a single cp operation but ¯(ツ)/¯