[英]boto3 will not upload a binary object to s3
我正在嘗試使用boto3和python 3.6將xls文件上傳到s3。 我需要能夠從內存而不是磁盤中的對象上載。
ep = 's3test.xlsx'
portfolio_binary = open(ep, "rb").read()
s3_client.put_object(Body=portfolio_binary, Bucket='test', Key='test/test/test.xlsx')
raise ParamValidationError(report=report.generate_report())
botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid type for parameter Body, value: <class '__main__.portfolio_object'>, type: <class 'type'>, valid types: <class 'bytes'>, <class 'bytearray'>, file-like object
這是一些更簡單的代碼:
import boto3
client = boto3.client('s3')
client.upload_file('/tmp/hello.txt', 'mybucket', 'hello.txt')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.