Updated on 2025-07-31 GMT+08:00

Deleting an Object or Folder

Scenarios

On OBS Console, you can manually delete unneeded files or folders to release space and reduce costs.

Alternatively, you can configure lifecycle rules to periodically, automatically delete some or all of the files and folders from a bucket. For details, see Configuring 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 case, 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 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 system creates a delete marker with an ID of null and 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, the version ID of the newly uploaded object is null. If an object with the same name and an empty version ID exists, the object will be overwritten by the uploaded 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 system creates 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 the object, delete it again from the Deleted Objects list.
    • To recover the deleted object, undelete it from the Deleted Objects list. For details, see Undeleting an Object.

Deleted noncurrent versions cannot be recovered.

Procedure

  1. In the navigation pane of OBS Console, choose Object Storage.
  2. In the bucket list, click the bucket you want to operate to go to the Objects page.
  3. Select the file or folder you want to delete and choose More > Delete on the right.

    You can select multiple files or folders and click Delete above the object list to batch delete them.

  4. Click OK to confirm the deletion.

    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:

  5. Permanently delete a file or a folder from a versioning-enabled OBS bucket:

    1. Enable Historical Versions.
    2. Select all the versions of the object to be permanently deleted and click Permanently Delete above the search bar.
      Figure 1 Permanently deleting an object
    3. Click OK.