Cloudinary supports delivering uploaded images as attachments using their original file names.
You can use the
flags transformation parameter to
attachment, or add
fl_attachment to transformation URLs.
The original file name of all newly uploaded images is now stored on our side for this purpose (for previously uploaded images the public ID would be used).
You can set the flags transformation parameter to attachment, or add fl_attachment to transformation URLs.
Here's a sample uploaded image delivered inline:
Same uploaded image with the attachment flag, downloaded as the original file name ('Custom File Name'):
When using our Ruby GEM, simply add
:flags => :attachment when building transformation URLs of uploaded images.
UPDATE: You can now change the name of the file on download by using
fl_attachment:<new_filename>. For example, to change the original file name to "new_sample" on download you can do the following:
Perfect, exactly what I needed! This stuff should all go into the documentation!
Thanks, please, how to do same thing for non image document ?
So, get an url like http://res.cloudinary.com/demo/????/upload/fl_attachment/v1362144095/sample_attachment.everything
As raw files cannot be transformed, the default behaviour is to download the document. For example,
For PDFs you can set the type to image and use the fl_attachment parameter, as usual.
I'm using fl_attachment to download transformation but it is downloading in webp format. I want to download in jpg format. What should I need to do?
If you're applying a specific fetch format (f_auto, f_webp) or changing the extension of the image in your URLs at the same time as requesting the fl_attachment transformation then that would explain why you're getting a WebP image when downloading.
If your originals are already in JPG format then you should ensure that the extension for the public_id stays as JPG and that there aren't any explicit fetch format transformations.
For example, the following "sample" image is already in JPG format within our Demo account.
I can deliver the image as an attachment by just including the fl_attachment transformation in the URL and keeping the existing extension untouched:
On the other hand, let's say the image was in a different (PNG) and I want to download it as a JPG, I can go ahead and set the fetch format (f param in URLs ) to JPG:
Hi, can you confirm what characters are not accepted as <new_filename>?
I was trying with single quotes (both unescaped as ' and escaped as %27) and I'm getting 400 Bad Request. Same for accented characters as á, é, í, ó, ú
I received a confirmation that it currently only accept any word character (letter, number, underscore), hyphen, space and exclamation mark.
Please sign in to leave a comment.