Skip to content

Instantly share code, notes, and snippets.

@abiydv
Last active July 12, 2021 03:36
Show Gist options
  • Save abiydv/0071aad9d9c2d36ccf381102bdae1372 to your computer and use it in GitHub Desktop.
Save abiydv/0071aad9d9c2d36ccf381102bdae1372 to your computer and use it in GitHub Desktop.
S3 Presigned url using boto3
curl -v "https://mybucket.s3.amazonaws.com/" \
-F "key=path/to/file.txt" \
-F "AWSAccessKeyId=access_key" \
-F "x-amz-security-token=security_token" \
-F "policy=base64_encoded_policy" \
-F "signature=signature" \
-F "file=@file.txt"
{
"url": "https://mybucket.s3.amazonaws.com/",
"fields": {
"key": "path/to/file.txt",
"AWSAccessKeyId": "access_key",
"x-amz-security-token": "security_token",
"policy": "base64_encoded_policy",
"signature": "signature"
}
}
import boto3
s3_client = boto3.client('s3', region_name='us-east-1')
resp = s3_client.generate_presigned_post("mybucket", "path/to/file.txt", ExpiresIn=600)
print(resp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment