1
votes

I have uploaded a number of directories that contain images, what is the correct way to modify the content-type to "image/jpeg" without having to re-upload the images?

I tried:

s3cmd modify s3://ccc-public/catalog/cropped/EP01L.jpg --add-header="Cache-Control:max-age=1296000" --mime-type="image/jpeg" --recursive -vvv

but the Content-Type always comes as binary/octet-stream

any advise much appreciated

4

4 Answers

2
votes

s3cmd has recently (as in, this past weekend) fixed this, but the code is not yet upstream. Please try with this branch:

https://github.com/mdomsch/s3cmd/tree/bug/content-type

With a little more testing, this will get merged into upstream.

Then, your command should work exactly as you expect. -mdomsch, s3cmd maintainer

3
votes

These days, it is recommended to use the official Amazon Command Line Interface (CLI).

The aws s3 cp command includes options for specifying mime-type, but by default the mime type of a file is guessed when it is uploaded.

2
votes

Ran into this recently as well and used some of the info here How can i change AWS S3 content type only for audio files

For us, it came down to ensuring that you change the content-type with the following

--add-header='content-type':'image/png'  

I want to emphasize using the lower case content-type vs Content-Type here. That's what ended up making a difference.

0
votes

--add-header did not help for me. But the below worked.

s3cmd put style.css -m 'text/css' s3://mybucket