delete_object Method
Deletes an object.
Syntax
def delete_object(object_name: str) -> None: ...
Remarks
This method deletes the object specified by ObjectName in the bucket currently selected by bucket.
If the version_id property is non-empty, this method deletes the specified version of the object instead.
Deleting Versioned Objects
If a bucket has versioning enabled (i.e., versioning_enabled returns True when queried), and this method is called on an object rather than a specific object version, then instead of actually deleting any data, the server will simply create a special object version called a delete marker.If an object's latest version is a delete marker, then the server treats the object as if it didn't exist (i.e., it doesn't appear when listing objects, cannot be downloaded, etc.). However, all of the previous versions of the object (including one that existed just before the delete marker was created) still exist; they can be listed using list_versions, and explicitly interacted with by setting version_id and calling an appropriate method.
To permanently delete objects in a versioning-enabled bucket, each version of the object must be explicitly deleted by setting version_id before calling this method. This includes any delete marker versions, which can be deleted like any other version.
Refer to Amazon's Deleting Object Versions, Working with Delete Markers, and Removing Delete Markers articles for more information.