Updated on 2023-07-17 GMT+08:00

Deleting an Object

Scenarios

You can delete unwanted files or folders to save storage space and reduce costs.

If versioning is not enabled for a bucket, deleted objects cannot be recovered. Exercise caution when performing this operation.

Manually or Automatically Deleting Objects

You can manually delete objects anytime. Alternatively, you can use lifecycle rules to periodically delete objects from a bucket or clear all objects in a bucket at a time.

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 an Object or a Batch of Objects

You can delete one or more objects at a time. For details about how to delete objects in batches, see Does OBS Support Batch Deletion of Objects?

The batch deletion performance is negatively correlated with the number of objects in a single request. When it comes to QPS, deleting N objects is counted as N operations. If a large number of objects named with prefixes in lexicographic order are deleted, lots of requests may be concentrated in a specific partition, which results in hot access. This limits the request rate in the hot partition and increases access delay.

To address this problem, you can reduce the number of objects in a single batch deletion request, initiate more concurrent requests, and name objects with random prefixes.

Object Deletion Mechanism When Versioning Is Enabled

When versioning is enabled, OBS uses different deletion methods for different objects.

  • Deleting a file or folder does not delete it permanently. The deleted file or folder will be retained in the Deleted Objects list and marked with the Delete Marker.
    • If you want to delete the file or folder permanently, you need to delete it from the Deleted Objects list.
    • To recover a deleted file, you can cancel the deletion by the Undelete operation. For details, see Undeleting an Object.
  • Deleting a version of an object will permanently delete that version. If the deleted version is the latest one, the next latest version becomes the latest version.
When versioning is enabled, files in the Deleted Objects list also have multiple versions. Note the following points when deleting different versions of files:
  • If you delete a version with the Delete Marker, it actually recovers that specific version instead of permanently deleting it. For details, see Undeleting an Object.
  • If you delete a version without the Delete Marker, that specific version is deleted permanently. Even if the object is recovered later, this version will not be recovered.

For more information, see Object Recovery Mechanism When Versioning Is Enabled.

How to Use

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

Tool

Reference

OBS Console

Deleting a File or Folder

SDKs

OBS supports software development kits (SDKs) in multiple languages. For details, see the corresponding developer guide on the SDK Overview page.

API

Deleting an Object

OBS Browser+

Deleting a File or Folder

obsutil

Deleting an Object