S3 / Client / generate_presigned_post
generate_presigned_post#
- S3.Client.generate_presigned_post(Bucket, Key, Fields=None, Conditions=None, ExpiresIn=3600)#
Builds the url and the form fields used for a presigned s3 post
- Parameters:
Bucket (string) – The name of the bucket to presign the post to. Note that bucket related conditions should not be included in the
conditions
parameter.Key (string) – Key name, optionally add ${filename} to the end to attach the submitted filename. Note that key related conditions and fields are filled out for you and should not be included in the
Fields
orConditions
parameter.Fields (dict) –
A dictionary of prefilled form fields to build on top of. Elements that may be included are acl, Cache-Control, Content-Type, Content-Disposition, Content-Encoding, Expires, success_action_redirect, redirect, success_action_status, and x-amz-meta-.
Note that if a particular element is included in the fields dictionary it will not be automatically added to the conditions list. You must specify a condition for the element as well.
Conditions (list) –
A list of conditions to include in the policy. Each element can be either a list or a structure. For example:
[ {"acl": "public-read"}, ["content-length-range", 2, 5], ["starts-with", "$success_action_redirect", ""] ]
Conditions that are included may pertain to acl, content-length-range, Cache-Control, Content-Type, Content-Disposition, Content-Encoding, Expires, success_action_redirect, redirect, success_action_status, and/or x-amz-meta-.
Note that if you include a condition, you must specify a valid value in the fields dictionary as well. A value will not be added automatically to the fields dictionary based on the conditions.
ExpiresIn (int) – The number of seconds the presigned post is valid for.
- Return type:
dict
- Returns:
A dictionary with two elements:
url
andfields
. Url is the url to post to. Fields is a dictionary filled with the form fields and respective values to use when submitting the post. For example:{ 'url': 'https://amzn-s3-demo-bucket.s3.amazonaws.com', 'fields': { 'acl': 'public-read', 'key': 'mykey', 'signature': 'mysignature', 'policy': 'mybase64 encoded policy' } }