I am trying to use AWS Api to set the content type of several objects and add the header "content-encoding: gzip" to them. Here is my code for this:
for (S3ObjectSummary summary : objs.getObjectSummaries() ) { String key = summary.getKey(); if (! key.endsWith(".gz")) continue; ObjectMetadata metadata = new ObjectMetadata(); metadata.addUserMetadata("Content-Encoding", "gzip"); metadata.addUserMetadata("Content-Type", "application/x-gzip"); final CopyObjectRequest request = new CopyObjectRequest(bucket, key, bucket, key) .withSourceBucketName( bucket ) .withSourceKey(key) .withNewObjectMetadata(metadata); s3.copyObject(request); }
When I run this, this is the result:

As you can see, the prefix x-amz-meta was added to my custom headers, and they were below. And the content-type header was ignored, instead it put www/form-encoded as the header.
What can I do to make it accept the values of my header?
java amazon-s3 amazon-web-services
Click upvote
source share