Performing a Multipart Copy
If you have any questions during development, post them on the Issues page of GitHub. For details about parameters and usage of each API, see the API Reference.
As a special case of multipart upload, multipart copy implements multipart upload by copying the whole or partial object in a bucket. You can call ObsClient.copyPart to copy parts. Sample code is as follows:
// Create an instance of ObsClient.
var obsClient = new ObsClient({
access_key_id: '*** Provide your Access Key ***',
secret_access_key: '*** Provide your Secret Key ***',
server : 'https://your-endpoint'
});
var destBucketName = 'destbucketname';
var destObjectKey = 'destobjectname';
var sourceBucketName = 'sourcebucketname';
var sourceObjectKey = 'sourceobjectname';
obsClient.CopyPart({
Bucket : destBucketName,
Key : destObjectKey,
// Set the part number, which ranges from 1 to 10000.
PartNumber : 1,
// Set the upload ID.
UploadId : 'upload id from initiateMultipartUpload',
// Set the source object to be copied.
CopySource : sourceBucketName + '/' + sourceObjectKey,
// Set the to-be-copied range of the source object.
CopySourceRange : 'bytes=0-100'
}, function(err, result) {
if (err) {
console.log('Error-->' + err);
} else {
console.log('Status-->' + result.CommonMsg.Status);
if (result.CommonMsg.Status < 300 && result.InterfaceResult) {
console.log('RequestId-->' + result.InterfaceResult.RequestId);
console.log('LastModified-->' + result.InterfaceResult.LastModified);
console.log('ETag-->' + result.InterfaceResult.ETag);
}
}
});
Use the PartNumber parameter to specify the part number, the UploadId parameter to specify the globally unique ID for the multipart upload, the CopySource parameter to specify the information about the source object, and the CopySourceRange parameter to specify the copy range.
Last Article: Performing an Appendable Upload
Next Article: Performing a Resumable Upload
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.