Skip to main content

DeleteObject

Removes an object from a bucket. The behavior depends on the bucket's versioning state:

  • If bucket versioning is not enabled, the operation permanently deletes the object.

  • If bucket versioning is enabled, the operation inserts a delete marker, which becomes the current version of the object. For more information about versioning-enabled buckets, see Deleting object versions from a versioning-enabled bucket.

  • If bucket versioning is suspended, the operation removes the object that has a null versionId, if there is one, and inserts a delete marker that becomes the current version of the object. If there isn't an object with a null versionId, and all versions of the object have a versionId, Astran S3 does not remove the object and only inserts a delete marker. For more information about versioning-suspended buckets, see Deleting objects from versioning-suspended buckets.

To permanently delete an object in a versioned bucket, you need to include the object's versionId in your request, specifying the version you wish to remove. This requires using the versionId query parameter, which ensures the specified version is permanently deleted. If the deleted object is a delete marker, the response header will have a x-amz-delete-marker set to true.

Permissions

ActionDescriptionResource
DeleteObjectGrants permission to delete an object from a bucketobject
DeleteObjectVersionGrants permission to delete a specific version of an object from a bucketobject
caution

Having the DeleteObject permission does not grant you DeleteObjectVersion permission, and vice versa. Each permission is independent of the other.

The following action is related to DeleteObject:

Request Syntax

DELETE /Bucket/Key+?versionId=VersionId HTTP/1.1
Host: <partition>.s3.astran.io

URI Request Parameters

The request uses the following URI parameters.

Bucket

The bucket name of the bucket containing the object.

Required: Yes

Key

Key name of the object to delete.

Length Constraints: Minimum length of 1.

Required: Yes

versionId

Version ID used to reference a specific version of the object.

Request Body

The request does not have a request body.

Response Syntax

HTTP/1.1 204
x-amz-delete-marker: DeleteMarker
x-amz-version-id: VersionId

The response returns the following HTTP headers.

x-amz-delete-marker

Indicates whether the specified object version that was permanently deleted was (true) or was not (false) a delete marker before deletion. In a simple DELETE, this header indicates whether (true) or not (false) the current version of the object is a delete marker.

x-amz-version-id

Returns the version ID of the delete marker created as a result of the DELETE operation.

Response Elements

If the action is successful, the service sends back an HTTP 204 response.

Examples

Sample Request for general purpose buckets

The following request deletes the object my-second-image.jpg.

            DELETE /bucket/my-second-image.jpg HTTP/1.1
Host: <partition>.s3.astran.io
Date: Mon, 25 Sep 2024 09:09:17 GMT
Authorization: authorization string

Sample Response for general purpose buckets

This example illustrates one usage of DeleteObject.

            HTTP/1.1 204 NoContent
x-request-id: 0A49CE4060975EAC
x-amz-date: 20240925T090917Z
Content-Length: 0
Connection: close

Sample Request for general purpose buckets: Deleting a specified version of an object

The following request deletes the specified version of the object my-third-image.jpg.

            DELETE /bucket/my-third-image.jpg?versionId=some_version_id HTTP/1.1
Host: <partition>.s3.astran.io
Date: Mon, 25 Sep 2024 09:09:17 GMT
Authorization: authorization string

Sample Response for general purpose buckets

This example illustrates one usage of DeleteObject.

            HTTP/1.1 204 NoContent
x-request-id: 0A49CE4060975EAC
x-amz-version-id: some_version_id
x-amz-date: 20240925T090917Z
Content-Length: 0
Connection: close

Sample Response for general purpose buckets: If the object deleted is a delete marker

This example illustrates one usage of DeleteObject.

            HTTP/1.1 204 NoContent
x-request-id: 0A49CE4060975EAC
x-amz-version-id: some_version_id
x-amz-delete-marker: true
x-amz-date: 20240925T090917Z
Content-Length: 0
Connection: close

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: