4

I tried the following options, but none of them will work

  • metadata.setCacheControl("max-age=604800, must-revalidate");
  • metadata.addUserMetadata("x-amz-meta-Cache-Control", "max-age=31536000, must-revalidate");

  • metadata.setHeader("x-amz-meta-Cache-Control", "max-age=31536000, must-revalidate");

  • metadata.addUserMetadata("Cache-Control", "max-age=31536000, must-revalidate");

Kindly help me to resolve this...

2
  • Are you sure it isn't the first one? That seems correct. Commented Jun 19, 2017 at 23:18
  • yes, michael, first one is correct. My Mistake is I passed metadata in PutObjectRequest instead of transferManager.upload(). Now its working fine. Thanks ... Commented Jul 5, 2017 at 10:43

1 Answer 1

5

First one is the correct approach, what i did wrong is, passed metadata via PutObjectRequest instead of TransferManager upload method. Need to pass metadata in TransferManager upload method.

metadata.setCacheControl("max-age=604800, must-revalidate");

Not Correct:

ObjectMetadata metadata = new ObjectMetadata();
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, PREFIX + folderName + DELIMITER, null, metadata);

correct :

ObjectMetadata metadata = new ObjectMetadata();
metadata.setCacheControl("max-age=31536000, must-revalidate");
Upload upload = transferManager.upload(bucketName, PREFIX + folderName + DELIMITER + fileName, fileStream, metadata);

Now its working fine.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.