Help Center/ Object Storage Service/ SDK Reference/ Java/ FAQs (SDK for Java)/ How Can I Perform a Multipart Upload? (SDK for Java)
Updated on 2024-12-11 GMT+08:00

How Can I Perform a Multipart Upload? (SDK for Java)

In a multipart upload, you can specify a part of the file to be uploaded by performing the following steps:

  1. Initialize an instance of ObsClient based on the AK, SK, and endpoint.
  2. Specify the bucket name and object name to initialize InitiateMultipartUploadRequest. Call InitiateMultipartUploadRequest.setMetadata to specify the metadata of the object to be uploaded. Then, call ObsClient.initiateMultipartUpload to initiate a multipart upload task. A globally unique identifier (upload ID) for this task will be returned.
  3. Specify the bucket name and object name to initialize UploadPartRequest. Call UploadPartRequest.setUploadId to specify the upload ID to which the part to be uploaded corresponds. Call setPartNumber to specify the part number of the part. Call setFile to specify the large file to which the part belongs. Call setPartSize to specify the part size. Then, call ObsClient.uploadPart to upload the part. The ETag value of the uploaded part is returned.
  4. After all parts are uploaded, specify the bucket name, object name, uploadId, and partEtags to initialize a CompleteMultipartUploadRequest request. Then, call ObsClient.completeMultipartUpload to assemble parts.

For details, see Multipart Upload (SDK for Java).