How can I make a download button with Cloudinary and Javascript? Getting CORS error
I am trying to create a download image button. I've tried several ways and still having trouble with CORS.
Does Cloudinary support CORS headers?
I am using Javascript/NodeJS.
I have tried using a fetch request with CORS headers but it seems like Cloudinary isn't reciprocating.
Any help on this?
Thanks.
Best Answer
-
Hi,
Regardless of if you are using a
button
element or a simple anchor, you can simply use the fl_attachment parameter to make an image URL downloadable.If you click on this URL: https://res.cloudinary.com/demo/image/upload/sample.jpg, it will open it on your browser. If you click on the
fl_attachment
URL: https://res.cloudinary.com/demo/image/upload/fl_attachment/sample.jpg, it will download it.Hope that helps.
Best,
Loic
1
Answers
-
Wow! That actually works! Thanks so much! I would have never thought to look in the Transformation part of the documentation.
0