Reputation: 110462
I have the following image file:
https://s3-us-west-1.amazonaws.com/premiere-avails/008378019847.jpg
If you click on the link, it will force a download to your browser. How would I get this file instead to open in the browser, such as how the following link does? https://lh3.googleusercontent.com/-r-NV4YMr0Gc/AAAAAAAAAAI/AAAAAAAAFvE/BcDknpxfm7M/s120-c/photo.jpg
I would like to use boto
in a bulk operation to accomplish this.
Upvotes: 1
Views: 1730
Reputation: 139
You can set this before sending the image to s3
import boto
conn = boto.connect_s3(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
bucket = conn.get_bucket("your-bucket")
key = bucket.new_key("your-key")
key.content_type = "image/jpeg"
key.set_contents_from_string("content")
key.make_public()
Upvotes: 0
Reputation: 25697
When I visit your image with Chrome's network inspector on, I see application/octet-stream
as the content-type
.
I think you need to specify the content-type
to be a image/jpeg
. I tested this on an S3 bucket and this fixed the 'problem' induced by it being an application/octet-stream
.
I don't know how to do bulk operations with boto, but this answer shows how to do it on a single object. You just want to change the content-type
metadata to be image/jpeg
.
Upvotes: 4