aws-cli icon indicating copy to clipboard operation
aws-cli copied to clipboard

s3 cp does not copy metadata within s3

Open huangting1 opened this issue 10 years ago • 10 comments

My command: aws s3 cp 's3://bucket/a' 's3://bucket/archive/b' --profile myprofile --metadata-directive COPY

I have some metadata on a that's not copied over to b after issuing the above command. Any idea?

huangting1 avatar Oct 25 '16 23:10 huangting1

To clarify: is some of the metadata being transferred?

JordonPhillips avatar Oct 26 '16 19:10 JordonPhillips

Content-Type is there, but none of x-amz-meta-* is transferred.

huangting1 avatar Oct 26 '16 19:10 huangting1

In that case, is the object large? There is a caveat in the docs:

Note that if the object is copied over in parts, the source object's metadata will not be copied over, no matter the value for --metadata-directive, and instead the desired metadata values must be specified as parameters on the command line.

JordonPhillips avatar Oct 26 '16 19:10 JordonPhillips

The object is ~58MB. The copy of metadata worked on the same file with native http PUT request (via x-amz-copy-source header). Why does the s3 command work inconsistently?

huangting1 avatar Oct 26 '16 20:10 huangting1

At that size, a multipart transfer would occur. Unfortunately, the multipart transfer api does not support copying metadata. If S3 added support then we could then support it. You can request that feature on the service forum.

JordonPhillips avatar Oct 26 '16 20:10 JordonPhillips

Hi I'm having the exact same issue, with the exact same command, however my files are not big, in fact, they're empty. They only have metadata, yet it's not being copied.

tiferrei avatar Oct 14 '19 11:10 tiferrei

I'm having the same issue @tiferrei. My files are also empty and can't seem to get the metadata to copy over. Did you ever figure out a workaround?

2WheelCoder avatar May 05 '20 20:05 2WheelCoder

@2WheelCoder honstely I ended up just using a super simple python script. Left it running for some minutes and it got the job done, but be sure to check your transfer and copy fees.

tiferrei avatar May 05 '20 20:05 tiferrei

@JordonPhillips I think this is a serious issue in the S3 API, and I understand that the AWS CLI team believes it's in the S3 team's court to address this. However, what this amounts to is silent loss of data while copying objects, since the metadata just gets dropped on the floor without warning above a certain opaque file size. I think that behavior is a bug and it is very unfortunate that neither team will own it while customers suffer from it. If metadata cannot be copied despite specifying --metadata-directive COPY, then at least the high level command (which aws s3 cp is) should error out.

kislyuk avatar Aug 11 '20 16:08 kislyuk

Do we have any update regarding this? I still see the metadata not moving to the new object at all for small files, by using --metadata-directive COPY

jinruxue-sony avatar Sep 12 '24 18:09 jinruxue-sony