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->createPostSignature(array $parameter)
Request Parameter
Field |
Type |
Optional or Mandatory |
Description |
---|---|---|---|
Bucket |
string |
Optional |
Bucket name |
Key |
string |
Optional |
Object name, which corresponds to the key field in the form |
Expires |
integer |
Optional |
Validity period of the browser-based upload authentication, in seconds. The default value is 300. |
FormParams |
associative array |
Optional |
Other parameters of the browser-based upload except for key, policy, and signature. Possible values are:
|
Returned Result
Field |
Type |
Description |
---|---|---|
OriginPolicy |
String |
Value of Policy that is not encoded by base64. This parameter can only be used for verification. |
Policy |
String |
policy in the form |
Signature |
String |
signature in the form |
Sample Code
try { $resp = $obsClient->createPostSignature( [ 'Bucket' => 'bucketname', 'Key' => 'objectkey', 'Expires' => 3600, 'FormParams' => [ 'acl' => 'public-read', 'content-type' => 'text/plain', ] ] ); printf ( "Policy:%s\n", $resp ['Policy'] ); printf ( "Signature:%s\n", $resp ['Signature'] ); } catch ( Obs\Common\ObsException $obsException ) { printf ( "ExceptionCode:%s\n", $obsException->getExceptionCode () ); printf ( "ExceptionMessage:%s\n", $obsException->getExceptionMessage () ); }
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.