Generating an attachment of a private image in Rails is done by calling the
cl_private_download_url view helper method, for example in Rails:
<%= link_to("Download", cl_private_download_url("my_private_image", :jpg, :attachment => true)) %>
Or by using Cloudinary::Utils.private_download_url from your model or controller, for example:
Cloudinary::Utils.private_download_url self.cloudinary_id, self.format, attachment: true
Is there something similar for authenticated assets ?
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:
Please try this out and let me know how it goes.
if I wanted to make a download button based on a cl_image_tag ?
You could try the below (where you replace `sample` with the public_id of the asset you want to download:
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:
You can also apply other transformations in the `cl_image_tag` method as described here (https://cloudinary.com/documentation/rails_image_manipulation#the_cl_image_tag_method).
Please try this out and let me know if it works for you.
Please sign in to leave a comment.