AWS S3 copy/paste does not copy metadata

2019-03-01 07:30发布

问题:

Using the Amazon web interface, it is possible to copy an S3 object from one bucket to another.

However, the pasted object does not have the metadata of the original. How can the metadata be pasted at the same time?

I'm guessing that the CLI can do it, but I can't figure out how.

Note, the metadata must be created with the object so it is available in the lambda function triggered on the S3 PUT.

回答1:

So I have figured out how to do it via the CLI.

aws s3 cp s3://<source bucket>/<filename> s3://<destination bucket>

The documentation states

--metadata-directive (string) Specifies whether the metadata is copied from the source object or replaced with metadata provided when copying S3 objects. ... Valid values are COPY and REPLACE. If this parameter is not specified, COPY will be used by default.

(My emphasis.)

All quite easy really. Very strange that the web interface does not do the same.