Help Center> Object Storage Service> SDK Reference> Python> Other APIs> Generating Browser-Based Upload Parameters with Authentication Information

Generating Browser-Based Upload Parameters with Authentication Information

API Description

You can use this API to generate parameters for authentication. The parameters can be used to upload data through POST operations based on a browser.

There are two request parameters generated:

  • policy corresponds to the policy field in the form.
  • signature corresponds to the signature field in the form.

Method Definition

ObsClient.createPostSignature(bucketName, objectKey, expires, formParams)

Request Parameters

Field

Type

Optional or Mandatory

Description

bucketName

str

Optional

Bucket name

objectKey

str

Optional

Object name, which corresponds to the key field in the form.

expires

int

Optional

Validity period of the browser-based upload authentication, in seconds. The default value is 300.

formParams

dict

Optional

Other parameters of the browser-based upload except for key, policy, and signature. Possible values are:

  • acl
  • cache-control
  • content-type
  • content-disposition
  • content-encoding
  • expires

Returned Results

Field

Type

Description

originPolicy

str

Value of policy that is not encoded by base64. This parameter can only be used for verification.

policy

str

policy in the form

signature

str

signature in the form

Sample Code

try:
    formParams = {'acl': 'public-read', 'content-type': 'text/plain'} 
    resp = obsClient.createPostSignature('bucketname', 'objectkey', 3600, formParams) 
    print('originPolicy:', resp.originPolicy) 
    print('policy:', resp.policy) 
    print('signature:', resp.signature)
except:
    import traceback
    print(traceback.format_exc())