Skip to main content

How can I generate a download/attachment URL for a private image?



  • countify

    Is there something similar for authenticated assets ?

  • Aleksandar Kostadinov

    Hi @countify,

    You can use the same method for "authenticated" type too. You would just need to pass the "type" parameter set to "authenticated" when calling the method. E.g. using Ruby SDK:

    Cloudinary::Utils.private_download_url('sample123', 'jpg', :type => "authenticated", :attachment => true)

    Please try this out and let me know how it goes.

  • Fernando Gonzalez

    if I wanted to make a download button based on a cl_image_tag ?

  • Aleksandar Kostadinov

    Hi Fernando,

    You could try the below (where you replace `sample` with the public_id of the asset you want to download:

    cl_image_tag("sample.jpg", :flags=>"attachment")

    That will return you a URL with the fl_attachment transformation that will download the asset on click instead of opening it inline.

    You can also set a custom name for the downloaded file per the structure below: 

    cl_image_tag("sample.jpg", :flags=>"attachment:my-custom-filename")

    You can also apply other transformations in the `cl_image_tag` method as described here (

    Please try this out and let me know if it works for you.


Please sign in to leave a comment.