1

Using CLI (not s3cmd) to manage Amazon S3, how can I select all objects with extension .pdf and apply the content type application/pdf?

This is what I came up with so far:

aws s3 sync s3://${BUCKET_NAME} s3://${BUCKET_NAME} --dryrun --exclude '*' --include '*.pdf' --no-guess-mime-type --content-type application/pdf 

Using the --debug parameter I found out about this error:

An error occurred (InvalidRequest) when calling the CopyObject operation: This copy request is illegal because it is trying to copy an object to itself without changing the object's metadata, storage class, website redirect location or encryption attributes. 
3
  • Can you try your command with no option. Then add option one by one to see when it fails ? Commented Dec 13, 2016 at 6:09
  • @Sylwit I used the --debug parameter, found the error and updated the question. Commented Dec 13, 2016 at 6:36
  • stackoverflow.com/a/58041788/4134265 Hope this helps Commented Sep 21, 2019 at 15:48

1 Answer 1

2

Try changing metadata directly:

aws s3 sync s3://${BUCKET_NAME} s3://${BUCKET_NAME} --dryrun --exclude '*' --include '*.pdf' --no-guess-mime-type --metadata Content-Type=application/pdf 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.