本文介绍了Boto3:将文件从base64上传到S3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用boto3将base64编码的文件直接上传到S3?
How can I directly upload a base64 encoded file to S3 with boto3?
object = s3.Object(BUCKET_NAME,email+"/"+save_name)
object.put(Body=base64.b64decode(file))
我试图像这样上载base64编码的文件,但随后该文件损坏了.直接上传字符串而不进行base64解码也不起作用.
I tried to upload the base64 encoded file like this, but then the file is broken. Directly uploading the string without the base64 decoding also doesn't work.
是否有与boto2中的set_contents_from_string()
类似的东西?
Is there anything similar to set_contents_from_string()
from boto2?
推荐答案
我刚刚解决了问题,发现上传方式正确,但是base64字符串不正确,因为它仍然包含前缀
I just fixed the problem and found out that the way of uploading was correct, but the base64 string was incorrect because it still contained the prefix
这篇关于Boto3:将文件从base64上传到S3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!