Listing Uploaded Parts
Function
This API is used to list the uploaded parts in a specified bucket. This request must contain the multipart upload ID.
You can list the uploaded parts of a specified multipart upload or of all ongoing multipart uploads. A maximum of 1,000 uploaded parts can be returned in a response. If your multipart upload has more than 1,000 parts, you need to send multiple requests to list all uploaded parts. Assembled parts will not be listed.
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.
Restrictions
- To list uploaded parts, you must be the bucket owner or have the required permission (obs:object:ListMultipartUploadParts granted using IAM or ListMultipartUploadParts granted using a bucket policy). For details, see Introduction to OBS Access Control, IAM Custom Policies, and Configuring an Object Policy.
- The mapping between OBS regions and endpoints must comply with what is listed in Regions and Endpoints.
Method
ObsClient.listParts(params)
Request Parameters
| Parameter | Type | Mandatory (Yes/No) | Description |
|---|---|---|---|
| Bucket | String | Yes | Explanation: Bucket name Restrictions:
Default value: None |
| Key | String | Yes | Explanation: Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path of the object that does not contain the bucket name. For example, if the address for accessing the object is examplebucket.obs.ap-southeast-1.myhuaweicloud.com/folder/test.txt, the object name is folder/test.txt. Value range: The value must contain 1 to 1,024 characters. Default value: None NOTE: The object URL is in the following format: https://Bucket name.Domain name/Folder directory level/Object name. If this object is stored in the root directory of the bucket, its URL does not contain the folder directory level. |
| RequestDate | String or Date | No | Explanation: Request time NOTE: When the parameter type is String, the value must comply with the ISO8601 or RFC822 standard. |
| UploadId | String | Yes | Explanation: Multipart upload ID, for example, 000001648453845DBB78F2340DD460D8 Value range: The value must contain 32 characters. Default value: None |
| MaxParts | Number | No | Explanation: Maximum number of parts that can be listed per page Restrictions: If the specified value is greater than 1000, only 1,000 parts are returned. Value range: The value ranges from 1 to 1000. Default value: 1000 |
| PartNumberMarker | Number | No | Explanation: Part number the listing starts from Restrictions: OBS only lists parts with greater numbers than that specified by this parameter. Default value: None |
Responses
| Parameter | Type | Description |
| Status | number | Explanation: HTTP status code returned by the OBS server Value range: A status code is a group of digits indicating the status of a response. It ranges from 2xx (indicating successes) to 4xx or 5xx (indicating errors). For details, see Status Codes. |
| Code | string | Explanation: Error code returned by the OBS server |
| Message | string | Explanation: Error description returned by the OBS server |
| HostId | string | Explanation: Request server ID returned by the OBS server |
| RequestId | string | Explanation: Request ID returned by the OBS server |
| Id2 | string | Explanation: Request ID2 returned by the OBS server |
| Indicator | string | Explanation: Error code details returned by the OBS server |
Sample Code: Simple Listing
The following example lists uploaded parts at a time.
// Create an ObsClient instance.
var obsClient = new ObsClient({
// Hard-coded or plaintext AK and SK are risky. For security purposes, encrypt your AK and SK before storing them in the configuration file or environment variables. In this example, the AK and SK are stored in environment variables. Before running the code in this example, configure environment variables AccessKeyID and SecretAccessKey.
// The front-end code does not have the process environment variable, so you need to use a module bundler like webpack to define the process variable.
// Obtain an AK/SK pair on the management console. For details, see https://support.huaweicloud.com/intl/en-us/usermanual-ca/ca_01_0003.html.
access_key_id: process.env.AccessKeyID,
secret_access_key: process.env.SecretAccessKey,
// CN-Hong Kong is used here in this example. Replace it with the one currently in use.
server: 'https://obs.ap-southeast-1.myhuaweicloud.com'
});
// List uploaded parts. uploadId is obtained from initiateMultipartUpload.
obsClient.listParts({
Bucket : 'bucketname',
Key: 'objectname',
UploadId : 'upload id from initiateMultipartUpload'
}, function (err, result) {
if(err){
console.log('Error-->' + err);
}else{
console.log('Status-->' + result.CommonMsg.Status);
if(result.CommonMsg.Status < 300 && result.InterfaceResult){
for(var i in result.InterfaceResult.Parts){
console.log('Part['+ i +']:');
// Part number, specified during the upload
console.log('PartNumber-->' + result.InterfaceResult.Parts[i]['PartNumber']);
// Time when the part was last uploaded
console.log('LastModified-->' + result.InterfaceResult.Parts[i]['LastModified']);
// Part ETag
console.log('ETag-->' + result.InterfaceResult.Parts[i]['ETag']);
// Part size
console.log('Size-->' + result.InterfaceResult.Parts[i]['Size']);
}
}
}
}); Sample Code: Listing All Parts
The following example lists all parts of a multipart upload when the number of parts exceeds 1,000.
// Create an ObsClient instance.
var obsClient = new ObsClient({
// Hard-coded or plaintext AK and SK are risky. For security purposes, encrypt your AK and SK before storing them in the configuration file or environment variables. In this example, the AK and SK are stored in environment variables. Before running the code in this example, configure environment variables AccessKeyID and SecretAccessKey.
// The front-end code does not have the process environment variable, so you need to use a module bundler like webpack to define the process variable.
// Obtain an AK/SK pair on the management console. For details, see https://support.huaweicloud.com/intl/en-us/usermanual-ca/ca_01_0003.html.
access_key_id: process.env.AccessKeyID,
secret_access_key: process.env.SecretAccessKey,
// CN-Hong Kong is used here in this example. Replace it with the one currently in use.
server: 'https://obs.ap-southeast-1.myhuaweicloud.com'
});
var listAll = function (partNumberMarker) {
// List uploaded parts. uploadId is obtained from initiateMultipartUpload.
obsClient.listParts({
Bucket : 'bucketname',
Key: 'objectname',
UploadId : 'upload id from initiateMultipartUpload',
PartNumberMarker : partNumberMarker
}, function (err, result) {
if(err){
console.log('Error-->' + err);
}else{
console.log('Status-->' + result.CommonMsg.Status);
if(result.CommonMsg.Status < 300 && result.InterfaceResult){
for(var i in result.InterfaceResult.Parts){
console.log('Part['+ i +']:');
// Part number, specified during the upload
console.log('PartNumber-->' + result.InterfaceResult.Parts[i]['PartNumber']);
// Time when the part was last uploaded
console.log('LastModified-->' + result.InterfaceResult.Parts[i]['LastModified']);
// Part ETag
console.log('ETag-->' + result.InterfaceResult.Parts[i]['ETag']);
// Part size
console.log('Size-->' + result.InterfaceResult.Parts[i]['Size']);
}
if(result.InterfaceResult.IsTruncated === 'true'){
listAll(result.InterfaceResult.NextPartNumberMarker);
}
}
}
});
};
listAll(); Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot