Aborting a Multipart Upload
Function
This API is used to abort a multipart upload using the multipart upload ID.
After a multipart upload is aborted, the upload ID cannot be used to upload any part, and the space occupied by all uploaded parts will be freed up. If any parts are being uploaded when you abort the upload, they may or may not be uploaded successfully. To free up the space occupied by all uploaded parts, you must abort the multipart upload after all parts have been uploaded.
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 abort a multipart upload, you must be the bucket owner or have the required permission (obs:object:AbortMultipartUpload granted using IAM or AbortMultipartUpload 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.abortMultipartUpload(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 |
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
After a multipart upload is aborted, you cannot use its upload ID to perform any operation and the uploaded parts will be deleted by OBS.
When an object is being uploaded or fails to be uploaded in multipart mode, parts are generated in the bucket. These parts occupy your storage space. You can abort the multipart upload to delete unnecessary parts, thereby saving the storage space.
You can call ObsClient.abortMultipartUpload to abort a multipart upload.
// 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.abortMultipartUpload({
Bucket:'bucketname',
Key:'objectname',
// Set the upload ID.
UploadId:'upload id from initiateMultipartUpload',
}, function (err, result) {
if(err){
console.log('Error-->' + err);
}else{
console.log('Status-->' + result.CommonMsg.Status);
}
}); 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