Help Center> OBS Nodejs SDK> API Reference> Other APIs> Generating Browser-Based Upload Parameters with Authentication Information
Updated on 2022-02-10 GMT+08:00

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, which corresponds to the policy field in the form
  • Signature: which corresponds to the signature field in the form

Method Definition

ObsClient.createPostSignatureSync

Request Parameter

Field

Type

Optional or Mandatory

Description

Bucket

String

Optional

Bucket name

Key

String

Optional

Object name, corresponds to the key field in the form

Expires

Number

Optional

Expiration time of the browser-based authentication (unit: seconds). The default value is 300.

FormParams

Object

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 Result

Field

Type

Description

OriginPolicy

String

policy not encoded by Base64. This parameter can only be used for verification.

Policy

String

policy in a form

Signature

String

signature in the form

Sample Code

var formParams = {acl: 'public-read', 'content-type': 'text/plain'};
var res = obsClient.createPostSignatureSync({Bucket: 'bucketname', Key: 'objectkey', Expires:3600, FormParams: formParams});

console.log('Policy-->' + res['Policy']);
console.log('Signature-->' + res['Signature']);