[英]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.