This topic describes how to delete objects.

Warning Deleted objects cannot be restored. Exercise caution when you delete objects.

The following code provides an example on how to delete an object:

OSSDeleteObjectRequest * delete = [OSSDeleteObjectRequest new];
delete.bucketName = @"<bucketName>";
// objectKey is equivalent to objectName and indicates the complete path of the object that you want to delete from OSS. The path must include the file extension of the object. For example, you can set objectKey to abc/efg/123.jpg.
delete.objectKey = @"<objectKey>";

OSSTask * deleteTask = [client deleteObject:delete];

[deleteTask continueWithBlock:^id(OSSTask *task) {
    if (! task.error) {
        // ...
    return nil;

// [deleteTask waitUntilFinished];
Note To delete an object, you must have write permissions on the bucket that contains the object.