Skip to main content

How to delete derived resources?

Comments

15 comments

  • Julien Bornstein

    Does delete_all_resources() can be used with a tag filter (delete_all_resources_by_tag() ?)

    0
  • Itay Taragano

    Deleting all resources sharing a certain tag can be performed with the  delete_resources_by_tag Admin API method, e.g., in PHP:

    $api->delete_resources_by_tag("mytag");

    For more information:

    http://cloudinary.com/documentation/admin_api#delete_resources_by_tags

    Note that each call deleted up to 1000 resources.

    0
  • Forrest Maready

    I deleted the resource (containing an incorrect image) before I realized that it wouldn't automatically delete the derived images. Is there any way to delete the derived resources of that now deleted resource? I deleted and recreated the resource, assuming all derived resources would be deleted. Obviously, it doesn't list the derived resources under the new resource, though the URLs are still live and showing an incorrect image.

    It seems like I now have no way to delete those "orphaned" resources.

     

    Thanks

    0
  • Itay Taragano

    Hi Forrest.

    Indeed deleting an image also deletes all its derivatives as well. However, note that both the original and the derived images might be still cached in the CDN.

    For more information:

    http://support.cloudinary.com/entries/23310776-I-have-deleted-an-image-and-though-it-has-been-removed-from-the-media-library-it-is-still-available-

    If you want the purge the CDN as well, you should set the  invalidate  parameter to  true  while deleting, for example in Rails:

    Cloudinary::Uploader.destroy('my_image', :invalidate => true)

    Deleting via the Media library automatically invalidates the image. Note that it may take up to an hour for the invalidation to fully propagate through the CDN.

    0
  • Forrest Maready

    Thank you Itay-

    Does the API call purge the CDN any faster than doing it through the Media Library?

     

    Many thanks

    0
  • Itay Taragano

    Invalidating either through the Admin API or the Media library may both take up to an hour. Note that this requests to propagate through Akamai's entire CDN network (100K+ servers in less than 1 hour).

    We warmly recommend to include the version component as part of the URL. Cloudinary's 'version' is a simple "cache busting" solution that acts as a unique name for each uploaded image. Unlike invalidation, 'versions' instantly bypasses all cached versions and force the delivery of the latest version of the image.

    For more information:

    http://support.cloudinary.com/entries/23663103-What-are-image-versions-

    0
  • aster

    Hi I have already set invalidate to "yes" under advanced settings. However, I am still getting the cache of the previous photo when i upload a new image with the same image name. I do not wish to keep track the version in the url and I would like to get the latest image just with the same URL. Could you help me with this? By the way I am using .Net.
    Thank you very much.

    [UPDATE] 
    I managed to resolve this issue by storing the version as I realized that no matter what version I provide in the URL e.g. "/v1" or "/v1486331234", it will return the latest image. Thanks

    0
  • Nadav Ofir

    Hi Aster,

    By default URLs that contain version components aren't invalidated.
    More information about the default invalidation policy is available here: https://support.cloudinary.com/hc/en-us/articles/209048985-Why-wasn-t-my-URL-properly-invalidated-

    If you're still encountering issues, please open a support ticket so we can look deeper into your use case.

    0
  • Jamie Nick Shepherd

    It seems exceptionally flawed that deleting derived resources by derived id lets you do a bulk delete, however no bulk search for derived ids is indicated.

    0
  • Zachary Gould

    Hey there Jamie, 

    If you know the transformation that you would like to delete assets for you can use the api find all associated derived assets by using our transformation details method. 

    cloudinary.v2.api
    .transformation({width: 150, height: 100, crop: 'fill'})
    .then(result=>console.log(result));


    If you're not sure which transformations you're currently using you can always get all transformations first and then iterate through them. 

    If you still run into any issues finding a specific resource please open a support ticket so we can help.

    0
  • Jamie Nick Shepherd

    This is the exact problem, if you have multiple transformations you need to delete resources for, iteration is unavoidable. This forces many admin api calls regardless of the bulk deletion method.

    It would be fantastic to see a bulk transformation details method or to optionally include derived asset ids when getting all transformations to resolve this issue.

    The use case for when this can happen is chained named transformations due to independent variables both adding a named transformation. For example if you were to have a named transformation to crop a video to 1080p, and a named transformation to add captions. It makes sense to have the cropping and captioning named transformations separate and chain them together as they should both be valid separately.

    0
  • John Roco

    Hi Jamie,

    Thank you for the response.

    As the feature to bulk delete derived resources via API is not currently supported, 

    I have submitted a feature request internally to see if it can be added to our roadmap. 

    Please also feel free to suggest this on our [public roadmap](https://cloudinary.com/roadmap)!

    Please let me know if there is anything else I can help you with!

    Best,
    John

    0
  • Jamie Nick Shepherd

    Hi John,

    Slightly confused here as the "delete_derived_resources" api lets you bulk delete 100 derived assets at a time from derived id - the issue is batch fetching the derived ids to use this method.

    0
  • John Roco

    Hi Jamie,

    Apologies for the confusion, I was responding with the details from our previous conversations in mind. In that conversation, you have two named transformations, i.e. `t_eng_caption` and `t_crop_for_customer`. In your transformations, you usually chain them - `t_eng_caption/t_crop_for_customer`. The request I opened was for the delete_derived_resources API to be able to accept `*t_crop_for_customer*` as a parameter and delete the derived along with its permutations.

    As you already know, `delete_derived_resources` has a prerequisite to iterate through necessary public_ids to get the derived `id` using the resource API.

    The feature request I submitted is to help with this use case, however, we cannot guarantee any ETA for it.

    Hope this clarifies the confusion.

     

     

    0
  • Jamie Nick Shepherd

    Hi John,

    Thanks for the clarification, that makes sense. Yes a wildcard like `*t_crop_for_customer*` would also be a very good and concise solution to the issue of permutations when chaining named transformations. Thanks for opening that request, will make things easier in the future.

    0

Please sign in to leave a comment.