[英]How to upload a base64 encoded string to s3 and access the url in html file in python
[英]For uploading a file to aws s3 bucket, how to calculate base64 encoded policy document
我正在尝试从HTML
模板将文件上传到AWS S3
存储桶,有人可以建议我如何在Python
计算base64
编码的策略文档吗?
尝试这个:
>>> 'VGV4dA==\n'.decode('base64')
"Text"
Python 2里的文件: https://docs.python.org/2.7/library/stdtypes.html#str.decode
Python的3文档: https://docs.python.org/3/library/stdtypes.html#bytes.decode
这是将策略文档加密为base64加密的Python代码:
import base64
input = open("policy.txt", "rb")
policy = input.read()
policy_encoded = base64.b64encode(policy)
print("%s" % (policy_encoded))
创建自己的策略文档为policy.txt
有关此的更多信息,请访问:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.