I have tried:
my_directory.files.create(key: key, body: body,
metadata: { custom: "x" })
And:
my_directory.files.create(key: key, body: body,
custom: "x" })
But the "custom" metadata is not showing up in the S3 web interface.
What am I doing it wrong? How should I do it?
According to Programming Amazon Web Services by James Murty (O'Reilly), page 74:
S3 does not allow you to set arbitrary metadata items to be returned as HTTP headers; only some header names are recognized as legal HTTP headers. Any header with a name the service does not recognize is discarded.
According to the properties panel of the Amazon S3 console, only these metadata fields are allowed:
- Cache-Control
- Content-Disposition
- Content-Type
- Content-Language
- Expires
- Content-Encoding
- x-amz-meta-
So, if you want to use custom metadata, make sure you use a key name that starts with x-amz-meta-
. That would be x-amz-meta-custom
for example above.
来源:https://stackoverflow.com/questions/12290819/how-to-upload-s3-metadata-with-a-file-in-fog