0
votes

We have approximately 250k images spread over 12000 folders hosted on S3. Some of them have been uploaded as content-type image/jpeg and some have been uploaded as binary/octet-stream. We also have a few partners that have scripts that automatically upload images and they seem to be inconsistent with the headers as well. Is there anyway to force all past, present and future images are served with the Content-Type header being set to image/jpeg?

I tried using S3 Bucket to do it but it doesn't seem to do much. I was wondering if there's a script or command I can run that would automatically do this.

Thanks

1
If you generate a signed URL for the object, you can append a query string of response-content-type=image/jpeg to the URL. It's unfortunately not possible on anonymous calls to an S3 URL.ceejayoz
@ceejayoz this can't be done even through policies?StackOverflowed
Not that I'm aware of.ceejayoz

1 Answers

1
votes

You might want to try using the command line Amazon S3 client s3cmd--- I believe you can do recursive operations on buckets with it. I've tried using S3 clients like S3 Bucket, Transmit to do large operations like this and it's never worked well.

If you're comfortable tinkering in Python a little, Boto would also be a great module to move recursively through keys and change the content-type with. It might the easiest way to this, in my experience.

I've grappled with this before, it's not fun. Good luck!