Updated on 2024-11-26 GMT+08:00

Deleting an Object

Scenarios

To save space and money, you can use OBS Console, the API, SDKs, OBS Browser+, or obsutil to delete unneeded objects.

The following describes how to manually delete objects. For details about the comparison between manual and automatic deletion, see Table 1.

Table 1 Object deletion methods

Method

Description

Rule

Manual deletion

Manual deletion is recommended for deleting a few or irregular objects.

  • Individual deletion
  • Batch deletion

Automatic deletion

To delete a large number of objects at a time or delete some objects periodically, you can configure lifecycle rules.

In big data scenarios, parallel file systems usually have deep directory levels and each directory has a large number of files. In such case, deleting directories from parallel file systems may time out. To address this problem, you are advised to delete directories in either of the following ways:

  1. On the Hadoop client that has OBSA, an OBS client plugin, embedded, run the hadoop fs - rmr obs://{Name of a parallel file system}/{Directory name} command.
  2. Configure a lifecycle rule for directories so that they can be deleted in background based on the preset lifecycle rule.

Deleting Objects from a Bucket with Versioning Disabled, Suspended, or Enabled

Deleting objects may cause data loss. Exercise caution when performing this operation. Versioning can reduce the risk by restoring objects that are accidentally deleted or overwritten.

Scenario

Deleting the Current Object Version

Deleting a Noncurrent Object Version

A versioning-disabled bucket

OBS permanently deletes objects. Deleted objects cannot be recovered.

N/A

A versioning-suspended bucket

  • If an object's current version does not have a delete marker and its version ID is not null, the object deletion operation turns the current version into a noncurrent version and inserts a delete marker with an ID of null. The delete marker then becomes the current version.
  • If an object's current version does not have a delete marker and its version ID is null, the object deletion operation inserts a delete marker with an ID of null that overwrites the current version. The delete marker then becomes the current version, and the overwritten version cannot be recovered.
  • If the current version has a delete marker, no action is taken.
    NOTE:
    • After versioning is suspended, a newly uploaded object will have a version ID of null. If the newly uploaded object has the same name as an existing object with a null version ID, this new object will overwrite the existing object. For more information about versioning, see Versioning.
    • By enabling Historical Versions in the object list, you can view the version ID of an object.

Deleted noncurrent versions cannot be recovered.

A versioning-enabled bucket

  • If an object's current version does not have a delete marker, the object deletion operation inserts a delete marker. Then, the current version becomes a noncurrent version and the delete marker becomes the current version.
  • If the current version has a delete marker, no action is taken.
    NOTE:
    • To permanently delete an object, delete it again from the Deleted Objects list.
    • To recover a deleted object, undelete it from the Deleted Objects list. For details, see Undeleting an Object.

Deleted noncurrent versions cannot be recovered.

Ways to Delete Objects

You can use OBS Console, APIs, SDKs, OBS Browser+, or obsutil to delete objects (folders included).