Updated on 2025-12-16 GMT+08:00

Deleting an Object

Scenarios

To save space and reduce costs, you can use OBS Console, APIs, SDKs, OBS Browser+, or obsutil to delete unwanted objects.

This section describes how to manually delete files or folders. 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 a lifecycle rule.

In big data scenarios, parallel file systems usually have deep directory levels and each directory has a large number of files. In such cases, deleting directories from parallel file systems may fail due to timeout. 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 Historical 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 historical 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 historical 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 historical version and the delete marker becomes the current version.
  • If an object's current version has a delete marker, permanently deleting the current version recovers the object.

Deleted historical versions cannot be recovered.

Ways to Delete Objects

You can use OBS Console, APIs, SDKs, OBS Browser+, or obsutil to delete files or folders.