There are a few ways to delete raw assets via the UI and API.
Via API
- Delete a single raw asset by public_id using the Upload API Destroy method
- Delete multiple raw assets by public_id using the Admin API Delete Resources method
Via UI
Via API
API calls are set to the image
resource type by default. In order to perform API calls for raw
assets, you should then set the resource_type
to raw
in the destroy
API call.
Delete a single raw asset by public_id using the Upload API Destroy method
Deleting a single asset can be done using the Upload API Destroy method, and our client SDKs provide methods to call this API from your application code.
For example, using our Node JS SDK, a simple call to delete an image asset called sample
is:
cloudinary.v2.uploader.destroy('sample', {resource_type: 'raw'})
.then(result => console.log(result))
You can try this below using your own account details
For more information about this API method, please see the documentation:
https://cloudinary.com/documentation/image_upload_api_reference#destroy_method
Delete multiple raw assets by public_id using the Admin API Delete Resources method
Deleting multiple raw assets can be done using the Admin API, and our client SDKs also provide methods to call this API from your application code.
For example, using our Node JS SDK, a simple call to delete 2 raw files called raw1
and raw2
is:
cloudinary.v2.api.delete_resources(['raw1', 'raw2'],
{ resource_type: 'raw' })
.then(result=>console.log(result));
You can try this below using your own account details
Using the Admin API, you can delete up to 100 specific public_id values in a single API call or up to 1000 assets when deleting all assets sharing a prefix, tag, etc.
The Admin API is rate-limited, so the best practice is to use the Upload API when deleting a small number of specific assets and to use the Admin API for infrequent bulk operations such as storage cleanups or removing assets related to products or features that are not required anymore.
Via UI
Delete raw resources individually
- Click on the Media Library tab
- In the search bar, select the
Asset types
filter then selectOthers (raw)
- Find the asset then click on the overflow icon (the three dots) and select
Delete
Bulk delete raw assets
- Go to your bulk delete page
- Select Originals and derived resources
- Under Search by, go to the last section and set:
Resource type
toRaw
Type
to the one of your choices
Comments
6 comments
Suppose i want to delete this file
res.cloudinary.com/dekmtxrqb/raw/upload/setixbbu9i03qnrczmbf.txt
then what should be the exact payload for this ?
\Cloudinary\Uploader::destroy('setixbbu9i03qnrczmbf.txt', array("resource_type" => "raw"));
am right?
Hi Rohit,
Thanks for reaching out.
Yes:) This is correct.
The default `resource_type` is `image` so when destroying `video` or `raw` files, you should set the appropriate `resource_type`.
How do I delete the resource which was created using a add-on ? like I have a used a add-on
Hi Aditya,
When using the Aspose Add-On, it generates a PDF which has the `resource_type:image` whereas the file uploaded has the `resource_type:raw`, hence you can run a deletion with those 2 types like this:
To delete the raw file in Python:
cloudinary.uploader.destroy('p5sxi8s04oiueembnt5k.xls', resource_type = 'raw')
To delete the PDF created via Aspose in Python:
cloudinary.uploader.destroy('p5sxi8s04oiueembnt5k.xls')
Best,
Loic
Thanks for the response,
I have to create a thumbnail for any resource uploaded on cloudinary(including "raw") is there a way to achieve it apart from using aspose ?
Hi Aditya,
Using Aspose is the only way to achieve the conversion from a `raw` file to a PDF with the `resource_type:image`. From there, you can then use transformations to generate the thumbnail.
You can find all the information on how to do it in this article.
Hope it helps.
Best,
Loic
Please sign in to leave a comment.