I have to reorganize S3 objects — basically move them around from one prefix to another.
I do this by copying the original object from the source path to a target path.
I would like to retain the original time stamps that are on the original object.
I am using the Java sdk to perform this task.
I am attempting to do this by:
// Create a meta object to apply to the new object
ObjectMetadata newObjectMetadata = new ObjectMetadata();
// Next I set the lat mod date on the new meta object from the old object summary
newObjectMetadata.setLastModified(Original_objectSummary.getLastModified());
// Next I create a CopyObjectRequest
CopyObjectRequest cor = new CopyObjectRequest(bucket, objectSummary.getKey(), bucket, targetKey);
// Next I set the new object meta data on the copy request
cor.setNewObjectMetadata(newObjectMetadata);
However when the object is created it has the last modified date as seen in the AWS management console set to the date the new object was created.
Any help or clarification appreciated.
Thanks.
When I needed to do this, I ended up having to save the original last_modified timestamp as a separate x-amz-meta- property, for the reason you specify. That was using other languages (Perl and Python), so I don’t think it’s a Java SDK issue.