List Multipart Uploads
Function
This API is used to list multipart uploads that have been initiated but not completed or aborted.
For each listing request, OBS can list a maximum of 1,000 multipart upload tasks. If there are more than 1,000 tasks, you need to send more than one request to list all of them.
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 multipart uploads, you must be the bucket owner or have the required permission (obs:bucket:ListBucketMultipartUploads granted using IAM or ListBucketMultipartUploads 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.
- By default, the bucket owner and the multipart upload initiator can perform this operation. The bucket owner can grant others the ListBucketMultipartUploads permission.
Method
ObsClient.listMultipartUploads(params)
Request Parameters
| Parameter | Type | Mandatory (Yes/No) | Description |
|---|---|---|---|
| Bucket | String | Yes | Explanation: Bucket name Restrictions:
Default value: None |
| Prefix | String | No | Explanation: Prefix that the object names in the multipart uploads to be listed must contain Assume that you have the following objects: logs/day1, logs/day2, logs/day3, and ExampleObject.jpg. If you specify logs/ as the prefix, the multipart uploads that contain logs/day1, logs/day2, or logs/day3 will be returned. If this parameter is left blank and there are no other filtering criteria, all multipart uploads in the bucket will be returned. Restrictions: The value must contain 1 to 1,024 characters. Default value: None |
| Delimiter | String | No | Explanation: Character used to group object names involved in multipart uploads. This parameter is often used with Prefix. If a prefix is specified, objects with the same string from the prefix to the first delimiter are grouped into one commonPrefixes. If no prefix is specified, objects with the same string from the first character to the first delimiter are grouped into one commonPrefixes. For example, there are three objects (abcd, abcde, and bbcde) in a bucket. If Delimiter is set to d and Prefix is set to a, objects abcd and abcde are grouped into a commonPrefixes with abcd as the prefix. If only Delimiter is set to d, objects abcd and abcde are grouped into a commonPrefixes with abcd as the prefix, and bbcde is grouped separately into another commonPrefixes with bbcd as the prefix. Value range: The value must contain 1 to 1,024 characters. Default value: None |
| MaxUploads | Integer | No | Explanation: Maximum number of multipart uploads to list Restrictions: If the specified value is greater than 1000, only 1,000 multipart uploads are returned. Value range: An integer from 1 to 1000 Default value: 1000 |
| KeyMarker | String | No | Explanation: Object name after which multipart upload listing begins Value range: Value of NextKeyMarker in the response body of the last request Default value: None |
| UploadIdMarker | String | No | Explanation: Upload ID after which the multipart upload listing begins Restrictions: This parameter is valid only when used with KeyMarker. If both parameters are specified, multipart uploads with IDs greater than the specified UploadIdMarker for the specified KeyMarker are listed. Value range: The value of NextUploadIdMarker in the response body of the last request Default value: None |
| EncodingType | String | No | Explanation: Encoding type for some elements in the response. If Delimiter, KeyMarker, Prefix, NextKeyMarker, and ObjectKey contain control characters that are not supported by the XML 1.0 standard, you can set EncodingType to encode Delimiter, KeyMarker, Prefix (including the Prefix in commonPrefixes), NextKeyMarker, and ObjectKey in response. Value range: url Default value: None. If you do not configure this parameter, encoding is not applied. |
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 |
| Parameter | Type | Description |
|---|---|---|
| Bucket | string | Explanation: Bucket name |
| KeyMarker | string | Explanation: Object name after which the multipart upload listing begins. This parameter corresponds to KeyMarker in the request. |
| UploadIdMarker | string | Explanation: Upload ID after which the multipart upload listing begins. This parameter corresponds to UploadIdMarker in the request. |
| NextKeyMarker | string | Explanation: Object name to start with for the next multipart upload listing request. This parameter is returned if some results were not returned. You can set KeyMarker in the next request to the returned value to list the remaining multipart uploads. |
| NextUploadIdMarker | string | Explanation: Upload ID to start with for the next multipart upload listing request. This parameter is used together with NextKeyMarker. This parameter is returned if some results were not returned. You can set UploadIdMarker in the next request to the returned value to list the remaining multipart uploads. |
| MaxUploads | number | Explanation: Maximum number of multipart uploads that can be listed. This parameter corresponds to MaxUploads in the request. |
| IsTruncated | boolean | Explanation: Whether all results are returned in the response Value range:
|
| Prefix | string | Explanation: Prefix that the object names in the multipart uploads to be listed must contain. This parameter corresponds to Prefix in the request. Assume that you have the following objects: logs/day1, logs/day2, logs/day3, and ExampleObject.jpg. If you specify logs/ as the prefix, the multipart uploads that contain logs/day1, logs/day2, or logs/day3 will be returned. If this parameter is left blank and there are no other filtering criteria, all multipart uploads in the bucket will be returned. |
| Delimiter | string | Explanation: Character used to group object names involved in multipart uploads. This parameter corresponds to Delimiter in the request. This parameter is often used with Prefix. If a prefix is specified, objects with the same string from the prefix to the first delimiter are grouped into one CommonPrefixes. If no prefix is specified, objects with the same string from the first character to the first delimiter are grouped into one CommonPrefixes. Assume that a bucket has objects abcd, abcde, and bbcde in it. If Delimiter is set to d and Prefix is set to a, objects abcd and abcde are grouped into a CommonPrefixes with abcd as the prefix. If only Delimiter is set to d, objects abcd and abcde are grouped into a CommonPrefixes with abcd as the prefix, and bbcde is placed separately into another CommonPrefixes with bbcd as the prefix. |
| Uploads | Upload[] | Explanation: List of multipart uploads. For details, see Table 4. |
| EncodingType | string | Explanation: Encoding type for Key in the response. If Key in the response contains control characters that are not supported by the XML 1.0 standard, you can specify this parameter to encode Key. |
| Parameter | Type | Description |
|---|---|---|
| Key | string | 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. |
| UploadId | string | Explanation: Multipart upload ID, for example, 000001648453845DBB78F2340DD460D8 |
| Initiator | Explanation: Initiator of the multipart upload. For details, see Table 5. | |
| Owner | Explanation: Account ID of the object owner. For details, see Table 6. | |
| StorageClass | Explanation: Storage class of the object involved in the multipart upload. For details about the storage classes, see Table 7. | |
| Initiated | string | Explanation: Time when the multipart upload was initiated |
| Parameter | Type | Description |
|---|---|---|
| ID | string | Explanation: Account (domain) ID of the initiator |
| DisplayName | string | Explanation: Account name of the initiator |
| Parameter | Type | Description |
|---|---|---|
| ID | string | Explanation: Account (domain) ID of the owner |
| DisplayName | string | Explanation: Account name of the owner |
| Constant | Original Value | Description |
|---|---|---|
| ObsClient.enums.StorageClassStandard | STANDARD | Standard storage class It features low access latency and high throughput, and is suitable for storing frequently accessed (multiple times a month on average) data or data that is smaller than 1 MB. |
| ObsClient.enums.StorageClassWarm | WARM | Infrequent Access storage class It is suitable for storing infrequently accessed (fewer than 12 times a year on average) data, but when needed, the access has to be fast. |
| ObsClient.enums.StorageClassCold | COLD | Archive storage class It is suitable for storing rarely accessed (once a year on average) data. |
Sample Code: Simple Listing
The following example lists multipart uploads 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'
});
obsClient.listMultipartUploads({
Bucket : 'bucketname'
}, 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.Uploads){
console.log('Uploads[' + i + ']');
console.log('UploadId-->' + result.InterfaceResult.Uploads[i]['UploadId']);
console.log('Key-->' + result.InterfaceResult.Uploads[i]['Key']);
console.log('Initiated-->' + result.InterfaceResult.Uploads[i]['Initiated']);
}
}
}
}); Sample Code: Listing All Multipart Uploads
The following example lists all multipart uploads.
// 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 (keyMarker, uploadIdMarker) {
obsClient.listMultipartUploads({
Bucket : 'bucketname',
KeyMarker : keyMarker,
UploadIdMarker : uploadIdMarker
}, 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.Uploads){
console.log('Uploads[' + i + ']');
console.log('UploadId-->' + result.InterfaceResult.Uploads[i]['UploadId']);
console.log('Key-->' + result.InterfaceResult.Uploads[i]['Key']);
console.log('Initiated-->' + result.InterfaceResult.Uploads[i]['Initiated']);
}
if(result.InterfaceResult.IsTruncated === 'true'){
listAll(result.InterfaceResult.NextKeyMarker, result.InterfaceResult.NextUploadIdMarker);
}
}
}
});
}
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