Delete Object

Using this SDK method, you can delete a particular object by passing the complete name of the object to the deleteObject() method. The Bucket reference used in the below code snippet is the component instance.

Parameters Used

Parameter Name Data Type Definition
key String A Mandatory parameter. Will hold the complete name of the object along with it's path.
options JSON Object
  • versionId: An optional String parameter. If Versioning is enabled for your bucket then, this param will help you refer to a particular version using its unique Version ID.
  • ttl: An optional String | Number parameter. You can set Time-to-Live (TTL) in seconds for an object. The value should be greater than or equal to 60 seconds.

Delete Object With Object Name

Using the following SDK method will delete the required object and all of its versions from the bucket.

    
copy
// Delete an object const deleteObject = await bucket.deleteObject("key");

Delete Object With Object Name and VersionID

Using the following SDK method will delete a specific version of the object.

    
copy
// Delete a specific version of an object after ttl time const options = { versionId: "01hthq82gwxtfyz6d9j8eg6k2f", // Delete an object with the given versionId ttl: 100 // Time to live in seconds }; const deleteObject = await bucket.deleteObject("key", options);

Example Response

    
copy
{ "status": 200, "content": {}, "message": "Object deleted successfully." }

Possible Exception

  • 404: Object or Bucket Not Found

Last Updated 2025-07-02 15:43:56 +0530 +0530