By using multipart upload and resumable upload provided by Alibaba Cloud OSS, you can split an object into multiple data blocks (parts) and upload them separately. After uploading all the object parts, you can call an API to combine them into an object.
When you use simple upload (through the PutObject API) to upload a large object to OSS, the upload may fail due to a network error. In the second upload attempt, you must upload the object from the beginning. In this case, you can use multipart upload to resume upload from the last uploaded part.
- Poor network connectivity: If the upload of one part fails on a mobile phone, you can re-upload only the failed part but not all parts.
- Resumable upload required: An upload in progress can be paused and resumed at any time.
- Upload acceleration: When the object to be uploaded to OSS is large, multiple parts can be uploaded concurrently to speed up the process.
- Streaming upload: Objects of unknown sizes can be uploaded at any time. This scenario is common in industry applications such as video surveillance.
|Java SDK||SDK demos in various languages|
- Size: The maximum size of an object is determined by the size of parts. Multipart upload supports a maximum of 10,000 parts. Each part must be at least 100 KB (except for the last part, which may be smaller) and no more than 5 GB. Therefore, the object size cannot exceed 48.8 TB.
- Naming rules
- Object names must be UTF-8 encoded.
- Object names must be one byte to 1,023 bytes in length.
- Object names cannot start with a forward slash (/) or a backslash (\).
Multipart upload process
The multipart upload process is as follows:
- Split the object to be uploaded into multiple parts.
- Initialize a multipart upload task (through the InitiateMultipartUpload API).
- Upload the parts one by one or concurrently (through the UploadPart API).
- Complete the upload (through the CompleteMultipartUpload API).
During the multipart upload process, you need to note the following items:
- Each part except the last one cannot be smaller than 100 KB. Otherwise, you may fail to call the CompleteMultipartUpload API.
- After the object to be uploaded is split into parts, they are sorted by partNumber specified during the upload. However, because upload in sequence is not required, the parts can be uploaded concurrently.
Due to network conditions and the device load, the upload does not necessarily speed up when more parts are uploaded concurrently. We recommend that you increase the part size in good network conditions, otherwise decrease the part size.
- By default, when all parts are uploaded but you have not called the CompleteMultipartUpload API, the uploaded parts are not deleted automatically. You can call the AbortMultipartUpload API to terminate the upload and delete the parts that occupy the storage space. For more information about how to automatically delete the uploaded parts, see Manage object lifecycle.
Upload security and authorization
To prevent unauthorized third-party users from uploading data to your bucket, OSS provides bucket- and object-level access control. For more information, see Access control.
To authorize third-party users to upload objects, OSS also provides account authorization. For more information, see Authorized third-party upload.