POST Object

最近更新时间:2020-07-13 21:30:54

POST Object


Description

This POST operation will use an HTML form to add an object for the specified space. POST is another option of PUT. In order to facilitate user space, users can upload objects based on browser. The parameter encapsulates the data code in the form field to the message body through POST instead of PUT. Users need write access to the space to add new objects.

KS3 will not add incomplete objects. If you receive a successful response, KS3 has successfully added objects to the response space.

KS3 is a distributed system. If multiple write requests from the same object are received at the same time, it will overwrite all the same objects and keep only the last one. KS3 does not provide object locking service when writing objects. If you really need it, please implement it in your application layer.

Request

Syntax

POST / HTTP/1.1
Host: {BucketName}.{endpoint}
User-Agent: {browser_data}
Accept: {file_types}
Accept-Language: {Regions}
Accept-Encoding: {encoding}
Accept-Charset: {character_set}
Keep-Alive: 300
Connection: keep-alive
Content-Type: multipart/form-data; boundary=9431149156168
Content-Length: {length}

--9431149156168
Content-Disposition: form-data; name="key"

{ObjectKey}
--9431149156168
Content-Disposition: form-data; name="KSSAccessKeyId"

{AccessKey}
--9431149156168
Content-Disposition: form-data; name="Policy"

{Policy}
--9431149156168
Content-Disposition: form-data; name="Signature"

{Signature}
--9431149156168
Content-Disposition: form-data; name="file"; filename="MyFilename.jpg"
Content-Type: image/jpeg

file_content
--9431149156168
Content-Disposition: form-data; name="submit"

Upload to KS3
--9431149156168--

Request Parameters

The request does not use the request parameter.

Request Headers

This request uses only the common request headers. For more information, please click Public Request Headers.

Form Fields

Name Description Required
acl Specifies the access control permission. If the specified access permission list is invalid, an error will be returned.
Type: String
Default: private
Valid Value: private &##124; public-read
No
Cache-Control, Content-Type, Content-Disposition, Content-Encoding, Expires REST Special header. For more information, see PUT Object
Type: String
Default: None
No
file File or text content. Users can only upload one file at a time, and the content must be placed in the last form field.
Type: File or text content
Default: None
Yes
key If you want to use the filename as the Key, you can use the ${filename} variable. For example, if the user wants to upload the file local.jpg and needs to indicate specify /user/betty/${filename}, the key value will be /user/betty/local.jpg.
Type: String
Default: None
Yes
KSSAccessKeyId KSSAccessKeyId。
Type:String
Default: None
Constraint: When bucket is not public-read-write or policy form field is provided, the form field must be provided.
Conditional
policy The security policy used in the request to describe the approved behavior. Requests without security policy are considered anonymous and can only access public writable space.
Type: String
Default: None
Constraint: The form field must be provided when the bucket is not public-read-write. See: Post Policy
Conditional
signature According to the signature information calculated by Access Key Secret and policy, KS3 verifies the signature information to verify the validity of the Post request.
Type: String
Default: None
Constraints:When bucket is not public-read-write or policy form field is provided, the form field must be provided. See:Post Policy
Conditional
success_action_redirect, redirect Redirect URL of the client after successful upload. If the user does not specify success_action_redirect, KS3 will return an empty file type. If KS3 cannot resolve the URL address, the form field is ignored. If the upload fails, KS3 will not redirect the client.
Type: String
Default: None
No
success_action_status The returned status code, if not specified, depends on the upload success status. The allowed values are 200, 201204 (default). If it is 200 or 204, KS3 will return an empty file with a status of 200 or 204. If the status code is 201, KS3 will return an XML document with the status code 201. If the value is invalid or not set, KS3 will return an empty document with status code 204.
Type: String
Default: None
No
x-kss-meta- User metadata prefix ID. If a header prefix is x-kss-meta-, user-defined metadata is used.
Type:String
Default: None
Constraints:None
No
x-kss-storage-class Set the storage class of the file.
Type:String
Default:None
Valid Value:STANDARD/STANDARD_IA/ARCHIVE
Notes:When x-kss-storage-class is not specified, if bucket is archive type, object will be archive type automatically. If bucket is non archive type, object will be standard type automatically. If x-kss-storage-class is specified, storage type will be specified.
Constraints:None
No
x-kss-newfilename-in-body After set file name in the console. Specifies whether the returned file name appears in the body. True means return in header and body. False means return only in header.
Type:boolean
Default:None
Valid Value:false|true
Constraints:None
No
Server-Side Encryption Specific Request Form Fields

If the user needs the server to use default encryption, the following form items are required.

Name Description Required
x-kss-server-side-encryption If server-side encryption is used to store object, this form item needs to be configured. The value is the encryption algorithm used. Currently, aes256 is supported.
Type:String
Yes

If the user needs the server to encrypt according to the secret key provided by the user, the following header is required.

Name Description Required
x-kss-server-side-encryption-customer-key The base64-encoded encryption key used by KS3 encryption is specified by the user.
Type:String
Constraint: required and valid x-kss-server-side-encryption-customer-algorithm,x-kss-server-side-encryption-customer-key-MD5 are used at the same time
Yes
x-kss-server-side-encryption-customer-algorithm If the server uses the encryption key provided by the user for encryption, the response will include the header to confirm the decryption algorithm used when the request is decrypted.
Type:String
Valid Value:AES256
Constraint: required and valid x-kss-server-side-encryption-customer-key,x-kss-server-side-encryption-customer-key-MD5 are used at the same time
Yes
x-kss-server-side-encryption-customer-key-MD5 If the server uses the encryption key provided by the user for encryption, the response will include the header to provide the data consistency verification information of the encryption key provided by the user when the request is decrypted.
Type:String
Constraint: required and valid x-kss-server-side-encryption-customer-key,x-kss-server-side-encryption-customer-algorithmare used at the same time
Yes

Response

Response Headers

This interface can use all common response headers. For more information, please click Public Response Headers

Name Description
success_action_redirect, redirect Redirect URL of the client after successful upload.
Type:String
Ancestor:PostResponse
x-kss-server-side-encryption-customer-algorithm If the server uses the encryption key provided by the user for encryption, the response will include the header to confirm the decryption algorithm used when the request is decrypted.
Type:String
Valid Value:AES256
x-kss-server-side-encryption-customer-key-MD5 If the server uses the encryption key provided by the user for encryption, the response will include the header to provide the data consistency verification information of the encryption key provided by the user when the request is decrypted.
Type:String
newfilename The new filename after set file name in the console
Type:String

Special Errors

The request does not return any special errors.

Interface Detail Analysis

  • Users need to have write permission to bucket
  • Unless anonymous users have write permission to Bucket, KSSAccesskeyId, policy and signature need to be provided in the form field. See Post Policy for the specific construction method
  • Content-Type must be multipart / form-data when POST Object
  • The policy specifies the rules that the form needs to meet. The form must meet the rules defined in the policy before it can be uploaded successfully. Policy must contain all form items in the form except KSSAccesskeyId, policy, signature, and file.policy
  • Users can add form items beginning with x-kss-meta to form items, which is regarded as adding user metadata. Note that these form items also need to be defined in the policy.
  • When KS3 returns 403, you should first check whether the form meets the policy

金山云,开启您的云计算之旅

免费注册