Skip to main content

How can I deliver an image as an attachment?

Comments

7 comments

  • Billy Silva

    Perfect, exactly what I needed!  This stuff should all go into the documentation!

    0
  • Yaka App

    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

    0
  • Maor Gariv

    As raw files cannot be transformed, the default behaviour is to download the document. For example,
    http://res.cloudinary.com/demo/raw/upload/SinglePageSample_kdca7x.docx

    For PDFs you can set the type to image and use the fl_attachment parameter, as usual.

    0
  • Mukesh Saxena

    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?

    0
  • Aleksandar Kostadinov

    Hi Mukesh,

    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:

    https://res.cloudinary.com/demo/image/upload/fl_attachment/sample.jpg

    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:

    https://res.cloudinary.com/demo/image/upload/fl_attachment,f_jpg/sample.png

    0
  • Lucas Velasco

    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 á, é, í, ó, ú 

    0
  • Lucas Velasco

    I received a confirmation that it currently only accept any word character (letter, number, underscore), hyphen, space and exclamation mark.

    0

Please sign in to leave a comment.