使用 boto 将图像上传到 s3
这里我有一个图像网址。文件名是图像 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")
将内容上传到 S3 但显示错误:
无法打开
/tmp/t.jpeg
,因为关联的帮助程序应用程序不存在。更改您的偏好设置中的关联。
Here I have an image url. filename is 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 upload things to the S3 but it shows the error:
/tmp/t.jpeg
could not be opened, because the associated helper application does not exist. Change the association in your preferences.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我很确定 images/jpeg 是一个拼写错误。正确的模仿类型是:
I'm pretty sure images/jpeg is a typo. The correct mimetype is:
该行有一些语法错误。将 .. 替换为 .
检查您尝试读取的图像文件的文件权限。从错误消息看来,您或至少您的程序没有对该文件的读取访问权限。
This line has some syntax error. replace .. with .
Check your file permission for the image file you are trying to read. From the error message it seems like you, or at least your program don't have read access to that file.