:doc:`S3 <../../s3>` / Client / generate_presigned_post

***********************
generate_presigned_post
***********************



.. py:method:: 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
  
  :type Bucket: string
  :param Bucket: The name of the bucket to presign the post to. Note that
      bucket related conditions should not be included in the
      ``conditions`` parameter.
  
  :type Key: string
  :param Key: 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`` or ``Conditions`` parameter.
  
  :type Fields: dict
  :param Fields: 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.
  
  :type Conditions: list
  :param Conditions: A list of conditions to include in the policy. Each
      element can be either a list or a structure. For example:
  
      .. code:: python
  
          [
              {"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.
  
  :type ExpiresIn: int
  :param ExpiresIn: The number of seconds the presigned post
      is valid for.
  
  :rtype: dict
  :returns: A dictionary with two elements: ``url`` and ``fields``.
      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:
  
      .. code:: python
  
          {
              'url': 'https://amzn-s3-demo-bucket.s3.amazonaws.com',
              'fields': {
                  'acl': 'public-read',
                  'key': 'mykey',
                  'signature': 'mysignature',
                  'policy': 'mybase64 encoded policy'
              }
          }
