yuliji
4/24/2017 - 5:43 AM

s3 presigned_post aws boto3

s3 presigned_post aws boto3

s3 = boto3.client(
    's3',
    aws_access_key_id=ACCESS_KEY,
    aws_secret_access_key=SECRET_KEY,
)

#get presigned url
data = s3.generate_presigned_post('lj1', 'hello2.mp3', Fields=dict(ACL='public-read'), Conditions=[{"acl": "public-read"}])

#upload file
files = {"file": open(filename, 'rb')}
response = requests.post(data["url"], data=data["fields"], files=files)