Upload image to s3 using boto

Here I have the image url. filename is the image URL.

def upload(filename, content) conn = S3Connection(aws_access_key, aws_secret_key) b = Bucket(conn, bucket_name) k = Key(b) k.key = filename..split('/')[::-1][0] k.set_metadata("Content-Type", 'images/jpeg') k.set_contents_from_string(content) k.set_acl("public-read") 

It loads things on S3, but shows an error:

/tmp/t.jpeg could not be opened because the associated helper application does not exist. Change the link in your settings.

+4
source share
2 answers

I'm sure the / jpeg images are a typo. The correct mimetype type is:

 image/jpeg 
+5
source
 k.key = filename..split('/')[::-1][0] 

There is a syntax error in this line. replace.

Check the file resolution for the image file you are trying to read. From the error message it seems to you, or at least your program does not have read access to this file.

+2
source

All Articles