Updated on 2026-09-10 GMT+08:00

Deleting an Object

Scenarios

You can use OBS Console, APIs, SDKs, OBS Browser+, or obsutil to delete unneeded files or folders, helping save space and reduce costs.

This section describes how to delete files or folders. For details, see Table 1.

Table 1 Object deletion methods

Scenario

Method

Description

In a bucket with versioning disabled

Individual deletion

To delete a small number of objects or objects without a clear pattern, select a specific object and delete it.

Batch deletion

To delete a large number of objects or periodically generated objects, select multiple objects and delete them in a batch. You can also use lifecycle rules to periodically delete objects for higher efficiency. For details, see Lifecycle Rules.

In a bucket with versioning enabled or suspended

Individual deletion

To delete a small number of objects or objects without a clear pattern, select a specific object and delete it.

Batch deletion

To delete a large number of objects or periodically generated objects, select multiple objects and delete them in a batch. You can also use lifecycle rules to periodically delete objects for higher efficiency. For details, see Lifecycle Rules.

In big data scenarios, parallel file systems often have deep directory hierarchies, and each directory contains a large number of files. As a result, directory deletion may time out. To address this issue, you can delete directories in either of the following ways:

  1. On a Hadoop client with OBSA embedded, run hadoop fs - rmr obs://{parallel-file-system-name}/{directory-name}.
  2. Configure a lifecycle rule for directories so that they can be deleted automatically in the background.

Important Notes

You can back up important objects to prevent accidental deletion. For details, see Copying Objects.

Access Control

Only the object owner and users granted the obs:object:DeleteObject (versioning disabled) or obs:object:DeleteObjectVersion (versioning enabled or suspended) permission can delete an object. The permissions can be granted through IAM or bucket policies. For details, see Creating a Custom Policy or Creating a Custom Bucket Policy.

If you have the required deletion permission in an IAM policy but still cannot delete an object, a Deny statement for obs:object:DeleteObject (versioning disabled) or obs:object:DeleteObjectVersion (versioning enabled or suspended) may be present in an SCP policy or bucket policy. Allow the permission and then delete the object.

How Object Deletion Works with Other Features

OBS versioning keeps multiple versions of an object in the same bucket. You can quickly search for and restore any version and recover data in the event of unintended actions or application failures. Deleting objects may cause data loss. Versioning reduces this risk by allowing you to restore objects that are accidentally deleted or overwritten. For more information, see Versioning.

Scenario

Deleting the Current Object Version

Deleting a Historical Object Version

In a bucket with versioning disabled

OBS permanently deletes objects. Deleted objects cannot be recovered.

N/A

In a bucket with versioning suspended

  • 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 a null version ID 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 null version ID. If the new object has the same name as an existing object with a null version ID, it overwrites the existing object.
    • By enabling Historical Versions above the object list, you can view the version ID of an object.

Deleted historical versions cannot be recovered.

In a bucket with versioning enabled

  • 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.

OBS automatically enables versioning when you enable WORM for a bucket. If you delete an object without specifying a version ID, OBS does not actually delete the object because of versioning. Instead, it inserts a delete marker with a unique version ID, which turns into the current version. If you specify a version ID when deleting an object protected by WORM, OBS blocks the deletion. Delete markers are not protected by WORM.

You can configure lifecycle rules to periodically delete unneeded objects to free up storage and reduce costs. When a lifecycle rule is executed, OBS performs different deletion operations on objects depending on the bucket's versioning status. For more information, see Using Lifecycle Rules to Delete or Transition Objects.

Ways to Delete Objects

You can use OBS Console, APIs, SDKs, OBS Browser+, or obsutil to delete files or folders. Up to 1,000 objects can be deleted at a time.

Deleting objects individually

  1. In the navigation pane of OBS Console, choose Buckets.
  2. In the bucket list, click the desired bucket. The Objects page is displayed.
  3. Select the file or folder you want to delete and choose More > Delete on the right.

    Figure 1 Deleting a file or folder

  4. Click OK to confirm the deletion.

    Figure 2 Deleting an object


    If you delete an object from a bucket with versioning enabled, the object is not permanently deleted but retained in the Deleted Objects list. All versions of the object are still kept in the bucket and are billed for storage. If you need to permanently delete the object, complete the following steps:

Batch deleting objects

To delete a large number of objects or periodically generated objects, select multiple objects and delete them in a batch.

  1. In the navigation pane of OBS Console, choose Buckets.
  2. In the bucket list, click the desired bucket. The Objects page is displayed.
  3. Select all files or folders or only the ones you want to delete and click Delete above the object list.
  4. Click OK to confirm the deletion.

    You can also use lifecycle rules to periodically delete objects for higher efficiency. For details, see Lifecycle Rules.

Deleting objects individually

  1. In the navigation pane of OBS Console, choose Buckets.
  2. In the bucket list, click the desired bucket. The Objects page is displayed.
  3. Enable Historical Versions.
  4. Select the file or folder to delete and click Permanently Delete above the search box.

    Figure 3 Permanently deleting an object

  5. In the dialog box, click OK.

Batch deleting objects

  1. In the navigation pane of OBS Console, choose Buckets.
  2. In the bucket list, click the desired bucket. The Objects page is displayed.
  3. Enable Historical Versions.
  4. Select all files or folders or only the ones you want to delete and click Permanently Delete above the search box.
  5. In the dialog box, click OK.

Logging and Monitoring

OBS provides logging and monitoring features that help you detect and handle deletion operations promptly. You can configure REST.PUT.NOTIFICATION to monitor object deletion. The system will record detailed logs for all object deletion operations for auditing or further analysis. For details, see Using Logging to Record OBS Logs.

Helpful Links