Appending an Object
Functions
The AppendObject operation adds data to the end of an object in a specified bucket. If there is no namesake object in the bucket, a new object is created.
The object created using the AppendObject operation is an appendable object, and the object uploaded using the PUT operation is a normal object.
Uploaded objects must be stored in buckets. Only the users who have the write permission to a bucket can upload objects to the bucket. The name of each object in the same bucket must be unique.
To ensure that data is not damaged during transmission, you can add the Content-MD5 parameter to the request header. After receiving the data, OBS performs MD5 verification for the data. If the data is inconsistent, OBS returns an error message.
This operation allows you to specify the x-obs-acl parameter when creating an appendable object and set the permission control policy for the object.
This operation supports server-side encryption.
Relationship with Other Operations
- If you perform the PUT operation on an existing appendable object, the appendable object is overwritten by the newly uploaded object and the object type changes to normal. If you perform the other way around, an error occurs.
- An appendable object will be changed to a normal object after being copied. An appendable object cannot be copied and saved as an appendable object.
WORM
If a bucket has WORM enabled, an append operation on this bucket will fail, with a 403 error returned.
Constraints
- The last modification time of the object is updated each time an appending upload is performed.
- If the SSE-C encryption mode is used on the server side, the appending upload is the same as the initialization segment. In this case, the request headers such as x-obs-server-side-encryption must be carried.
- For the server-side encryption (SSE-KMS), the request header such as x-obs-server-side-encryption is specified only when the file is uploaded for the first time and no object with the same name exists in the bucket.
- The length of each appended upload cannot exceed the upper limit (5 GB) of the object length.
- The maximum number of append-only writes for each appendable object is 10,000.
- If the object storage class is COLD (Cold), this API cannot be called.
- Object appending is not available for parallel file systems.
Request Syntax
POST /ObjectName?append&position=Position HTTP/1.1Host: bucketname.obs.region.example.comContent-Type: application/xmlContent-Length: lengthAuthorization: authorizationDate: date<Optional Additional Header><object Content>
Request Parameters
The request needs to specify parameters in the message, indicating that the request is for append upload and the upload location must be specified. For details about the parameters, see Table 1.
Parameter | Type | Mandatory (Yes/No) | Description |
---|---|---|---|
append | String | Yes | Explanation: Indicates that the object is uploaded in an append manner. Restrictions: None Value range: None Default value: None |
position | Integer | Yes | Explanation: Location for the append upload Restrictions: Max. 5 GB Value range: For an object to be appended, the value of position must be set to 0 when the object is uploaded for the first time. The value of position will be carried in the x-obs-next-append-position header of the response returned by the server when the object is successfully uploaded next time. Default value: None |
Request Headers
This request uses common headers. For details, see Table 3.
Table 2 describes the additional message headers that a request can use when position=0.
This request can use the server-side encryption request headers. For details, see Table 3.
Header | Type | Mandatory (Yes/No) | Description |
---|---|---|---|
x-obs-acl | String | No | Explanation: When first calling this API, you can use this parameter to set a pre-defined object ACL. Restrictions: Use character strings. Value range:
Default value: private |
x-obs-grant-read | String | No | Explanation: When first calling this API, you can use this header to grant all users in a domain the permissions to read the object and obtain the object metadata. Example: x-obs-grant-read: id=domainID Restrictions: Use commas (,) to separate multiple domains. Value range: None Default value: None |
x-obs-grant-read-acp | String | No | Explanation: When first calling this API, you can use this header to grant all users in a domain the permissions to obtain the object ACL. Example: x-obs-grant-read-acp: id=domainID Restrictions: Use commas (,) to separate multiple domains. Value range: None Default value: None |
x-obs-grant-write-acp | String | No | Explanation: When first calling this API, you can use this header to grant all users in a domain the permissions to write the object ACL. Example: x-obs-grant-write-acp: id=domainID Restrictions: Use commas (,) to separate multiple domains. Value range: None Default value: None |
x-obs-grant-full-control | String | No | Explanation: When first calling this API, you can use this header to grant all users in a domain the permissions to read the object, obtain the object metadata and ACL, and write the object ACL. Example: x-obs-grant-full-control: id=domainID Restrictions: Use commas (,) to separate multiple domains. Value range: None Default value: None |
x-obs-storage-class | String | No | Explanation: For the first write, you can use this header field to configure the object storage class. Example: x-obs-storage-class:STANDARD Restrictions:
Value range:
Default value: If you do not use this header, the object storage class is the default storage class of the bucket. |
x-obs-meta-* | String | No | Explanation: For the first write, you can use a header starting with x-obs-meta- to define object metadata in an HTTP request. Custom metadata will be returned in the response header when you retrieve or query the metadata of the object. Example: x-obs-meta-test:test metadata Restrictions: This parameter can only be passed in HTTP request headers and cannot exceed 8 KB. Value range: None Default value: None |
x-obs-website-redirect-location | String | No | Explanation: If a bucket is configured with the static website hosting function, it will redirect requests for this object to another object in the same bucket or to an external URL. OBS stores the value of this header in the object metadata. Restrictions: The value must start with a slash (/), http://, or https:// and cannot exceed 2K. Value range: None Default value: None |
x-obs-expires | Integer | No | Explanation: Specifies when an object expires. It is measured in days. Once the object expires, it is automatically deleted. (The calculation starts from when the object was last modified). Example: x-obs-expires:3 Restrictions: The value must be greater than the number of days that have passed since the object was created. For example, if the object was uploaded 10 days ago, you must specify a value greater than 10. Value range: The value is an integer greater than 0. Default value: None |
Header | Type | Mandatory (Yes/No) | Description |
---|---|---|---|
x-obs-server-side-encryption | String | No. This header is required when SSE-KMS is used. | Explanation: Indicates that SSE-KMS is used. Example: x-obs-server-side-encryption:kms Restrictions: None Value range:
Default value: None |
x-obs-server-side-encryption-kms-key-id | String | No | Explanation: ID of a specified key used for SSE-KMS encryption. Restrictions: This header can only be used when you specify kms for the x-obs-server-side-encryption header. Default value: If you specify kms for encryption but do not specify a key ID, the default master key will be used. If there is not a default master key, OBS will create one and use it. |
x-obs-server-side-encryption-customer-algorithm | String | No. This header is required when SSE-C is used. | Explanation: Indicates the encryption algorithm used when SSE-C is used. Example: x-obs-server-side-encryption-customer-algorithm:AES256 Restrictions: This header must be used together with x-obs-server-side-encryption-customer-key and x-obs-server-side-encryption-customer-key-MD5. Value range: AES256 Default value: None |
x-obs-server-side-encryption-customer-key | String | No. This header is required when SSE-C is used. | Explanation: Indicates the encryption key used when SSE-C is used. Example: x-obs-server-side-encryption-customer-key:K7QkYpBkM5+hca27fsNkUnNVaobncnLht/rCB2o/9Cw= Restrictions: This header is a Base64-encoded 256-bit key and must be used together with x-obs-server-side-encryption-customer-algorithm and x-obs-server-side-encryption-customer-key-MD5. Value range: None Default value: None |
x-obs-server-side-encryption-customer-key-MD5 | String | No. This header is required when SSE-C is used. | Explanation: Indicates the MD5 value of the encryption key when SSE-C is used. The MD5 value is used to check whether any error occurs during the transmission of the key. Example: x-obs-server-side-encryption-customer-key-MD5:4XvB3tbNTN+tIEVa0/fGaQ== Restrictions: This header is a Base64-encoded 128-bit MD5 value and must be used together with x-obs-server-side-encryption-customer-algorithm and x-obs-server-side-encryption-customer-key. Value range: Base64-encoded MD5 value of the key ID. Default value: None |
Request Elements
This request involves no elements.
Response Syntax
HTTP/1.1 status_codeDate: dateETag: etagContent-Length: length
Response Headers
The response to the request uses common headers. For details, see Table 1.
The ETag returns the hash value of the data to be uploaded, not the hash value of the entire object.
Header | Type | Description |
---|---|---|
x-obs-version-id | String | Explanation: Version ID of the object. If versioning is enabled for the bucket, the object version ID will be returned. Restrictions: None Value range: None Default value: None |
x-obs-server-side-encryption | String | Explanation: The encryption method used by the server. Example: x-obs-server-side-encryption:kms Restrictions: This header is included in a response if SSE-KMS is used. Value range:
Default value: None |
x-obs-server-side-encryption-kms-key-id | String | Explanation: ID of a specified key used for SSE-KMS encryption. Restrictions: This header can only be used when you specify kms for the x-obs-server-side-encryption header. Default value: If you specify kms for encryption but do not specify a key ID, the default master key will be used. If there is not a default master key, OBS will create one and use it. |
x-obs-server-side-encryption-customer-algorithm | String | Explanation: Indicates the encryption algorithm. This header is included in a response when SSE-C is used. Example: x-obs-server-side-encryption-customer-algorithm:AES256 Restrictions: None Value range: AES256 Default value: None |
x-obs-server-side-encryption-customer-key-MD5 | String | Explanation: Indicates the MD5 value of the key for encrypting objects. This header is included in a response when SSE-C is used. Example: x-obs-server-side-encryption-customer-key-MD5:4XvB3tbNTN+tIEVa0/fGaQ== Restrictions: None Value range: Base64-encoded MD5 value of the key ID. Default value: None |
x-obs-next-append-position | Integer | Explanation: Indicates the position to be provided for the next request. Restrictions: This header is returned when the object is an Appendable object. Value range: None Default value: None |
Response Elements
This response contains no elements.
Error Responses
- If the object length exceeds the limit due to the appending upload, OBS returns 400 Bad Request and the error code is AppendTooLarge.
- If the value of position is different from the original length of the current object, OBS returns 409 Conflict and the error code is PositionNotEqualToLength.
- If an object with the same object name exists in a bucket and the object type is not Appendable, OBS returns 409 Conflict and the error code is ObjectNotAppendable.
- If the number of write times of an object exceeds 10000, OBS returns 409 Conflict and the error code is ObjectNotAppendable.
- If the object storage class is COLD (Cold), this API cannot be called. If you still call this API, OBS returns 409 Conflict with the error code of ObjectNotAppendable.
Other errors are included in Table 2.
Sample Request: Append Upload
POST /object?append&position=0 HTTP/1.1Host: examplebucket.obs.region.example.comExpires: Wed, 27 Jun 2015 13:45:50 GMTDate: Wed, 08 Jul 2015 06:57:01 GMTContent-Type: image/jpgContent-Length: 1458Authorization: OBS H4IPJX0TQTHTHEBQQCEC:kZoYNv66bsmc10+dcGKw5x2PRrk=[1458 bytes of object data]
Sample Response: Append Upload
HTTP/1.1 200 OKDate: Wed, 27 Jun 2015 13:45:50 GMTETag: "d41d8cd98f00b204e9800998ecf8427e"Content-Length: 0Server: OBSx-obs-request-id: 8DF400000163D3F0FD2A03D2D30B0542x-obs-id-2: 32AAAUgAIAABAAAQAAEAABAAAQAAEAABCTjCqTmsA1XRpIrmrJdvcEWvZyjbztddx-obs-next-append-position: 1458
Sample Request: Append Upload (with redirect and a User-Defined Header Used)
The bucket examplebucket exists but the object obj001 does not exist. Create an object by making the API call for the append operation. Set the redirection header field as follows: "x-obs-website-redirect-location":"http://www.example.com/", and set the user-defined header field to: "x-obs-meta-redirect":"redirect". The request is as follows:
POST /obj001?append&position=0 HTTP/1.1Host: examplebucket.obs.region.example.comExpires: Wed, 27 Jun 2015 13:45:50 GMTDate: Wed, 08 Jul 2015 06:57:01 GMTx-obs-website-redirect-location: http://www.example.com/x-obs-meta-redirect: redirectContent-Length: 6Authorization: OBS H4IPJX0TQTHTHEBQQCEC:kZoYNv66bsmc10+dcGKw5x2PRrk=[6 bytes of object data]
Sample Response: Append Upload (with redirect and a User-Defined Header Used)
HTTP/1.1 200 OKDate: Wed, 27 Jun 2015 13:45:50 GMTETag: "9516dfb15f51c7ee19a4d46b8c0dbe1d"Content-Length: 0Server: OBSx-obs-request-id: 5DEB00000164A3150AC36F8F0C120D50x-obs-id-2: 32AAAUgAIAABAAAQAAEAABAAAQAAEAABCSrVlTYwsA4p9GEW+LYqotSl5BYDxHfTx-obs-next-append-position: 6
- Functions
- Relationship with Other Operations
- WORM
- Constraints
- Request Syntax
- Request Parameters
- Request Headers
- Request Elements
- Response Syntax
- Response Headers
- Response Elements
- Error Responses
- Sample Request: Append Upload
- Sample Response: Append Upload
- Sample Request: Append Upload (with redirect and a User-Defined Header Used)
- Sample Response: Append Upload (with redirect and a User-Defined Header Used)