Delete objects (OSS SDK for Python 2.0)
This topic describes how to use OSS SDK for Python 2.0 to delete a single object or multiple objects.
Usage notes
-
The sample code in this topic uses the China (Hangzhou) region ID
cn-hangzhouand a public endpoint by default. If you want to access OSS from other Alibaba Cloud services in the same region, use an internal endpoint. For more information about the mappings between OSS regions and endpoints, see Regions and endpoints. -
To delete an object, you must have the
oss:DeleteObjectpermission. For more information, see Grant custom permissions to a RAM user.
Method definition
Delete a single object
delete_object(request: DeleteObjectRequest, **kwargs) → DeleteObjectResult
Delete multiple objects
delete_multiple_objects(request: DeleteMultipleObjectsRequest, **kwargs) → DeleteMultipleObjectsResult
Request parameters
|
Parameter |
Type |
Description |
|
request |
DeleteObjectRequest |
The request parameters, such as the object name. For more information, see DeleteObjectRequest |
|
DeleteMultipleObjectsRequest |
The request parameters, such as the list of objects to delete. For more information, see DeleteMultipleObjectsRequest |
Return values
|
Type |
Description |
|
DeleteObjectResult |
The return value. For more information, see DeleteObjectResult |
|
DeleteMultipleObjectsResult |
The return value. For more information, see DeleteMultipleObjectsResult |
-
For the complete definition of the method for deleting a single object, see delete_object.
-
For the complete definition of the method for deleting multiple objects, see delete_multiple_objects.
Sample code
References
-
For the complete sample code for deleting a single object, see delete_object.py.
-
For the complete sample code for deleting multiple objects, see delete_multiple_objects.py.