I successfully add an image to the bucket on S3, but the problem is that I'm not sure how to set the content type to "image / png". Here is my code
image = Image.open(self.image) conn = S3Connection(settings.AWS_ACCESS_KEY_ID, settings.AWS_SECRET_ACCESS_KEY) out_im2 = cStringIO.StringIO() image.save(out_im2, 'PNG') b = conn.get_bucket('new_test_bucket') k = b.new_key(self.title+'.png') k.set_contents_from_filename(str(self.image))
It is currently loading as an โapplication / octet streamโ.
source share