gpt4 book ai didi

python - 使用 boto 在 s3 上上传图像

转载 作者:太空狗 更新时间:2023-10-30 02:23:24 24 4
gpt4 key购买 nike

这里我有一个图片 url。文件名是图片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 could not be opened, because the associated helper application does not exist. Change the association in your preferences.

最佳答案

我很确定 images/jpeg 是错字。正确的 mimetype 是:

image/jpeg

关于python - 使用 boto 在 s3 上上传图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4212173/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com