Append upload lets you append data to the end of an existing appendable object. This topic describes how to perform an append upload using the OSS SDK for Python V2.
Precautions
The sample code in this topic uses the China (Hangzhou) region, which has the region ID
cn-hangzhou, as an example. By default, a public endpoint is used. If you want to access OSS from other Alibaba Cloud services in the same region as OSS, you must use an internal endpoint. For more information about the mappings between OSS regions and endpoints, see OSS regions and endpoints.If the object does not exist, calling the append upload method creates an appendable object.
If the object exists:
If the object is an appendable object and the specified append position is the same as the current length of the object, the content is appended to the end of the object.
If the object is an appendable object but the specified append position is not the same as the current length of the object, a PositionNotEqualToLength exception is thrown.
If the object is not an appendable object, such as a normal object that is uploaded using simple upload, an ObjectNotAppendable exception is thrown.
Permissions
By default, an Alibaba Cloud account has full permissions. RAM users or RAM roles under an Alibaba Cloud account do not have any permissions by default. The Alibaba Cloud account or account administrator must grant operation permissions through RAM Policy or Bucket Policy.
API | Action | Definition |
AppendObject |
| You can call this operation to upload an object by appending the object to an existing object. |
| When uploading an object by appending the object to an existing object, if you specify object tags through x-oss-tagging, this permission is required. |
Method definitions
For append upload scenarios, the Python SDK V2 adds the AppendFile method to simulate file read and write operations on objects in a bucket. The following table describes the AppendFile and AppendObject methods.
Method | Description |
AppendFile | Provides the same features as the AppendObject method. Optimizes fault tolerance for retransmissions after a failure. |
AppendObject | Performs an append upload. The final object can be up to 5 GiB in size. Supports CRC-64 data validation (enabled by default). Supports progress bar charts. |
For the complete definition of the AppendObject method, see append_object.
Examples
Scenarios
References
For the complete sample code for append upload, see append_file.py and append_object.py.