How do I download images served by Cloudinary to my local directory using extendscript?

404 views Asked by At

If this is my url for the image: https://static.www.nfl.com/image/private/h_100,f_auto,q_auto,c_fill,g_auto/league/jccqiejlzdigw2zwxx2n

I've previously downloaded images from a url that was http and not a server in the following code but can't figure out how to download an image from cloudinary.

 var imageURL = "http://www.nfl.com/static/content/public/static/img/fantasy/transparent/512x512/";
 var imageName =  imageURL + playerID + ".png";
 var localFileImage = playerID + ".png";
 var fileRepository = "/01 feedRepository/IMAGE_FILES/";
 var playerName = playerLastName + "_" + playerFirstName;

 getJSONFile(imageName, fileRepository);
 ...

I've tried this, which works from the terminal but not from AE:

app.system.callSystem("curl -o ~/Desktop/OLU474619.png https://static.www.nfl.com/image/private/h_100,f_auto,q_auto,c_fill,g_auto/league/jccqiejlzdigw2zwxx2n.png");
2

There are 2 answers

0
sbaden On BEST ANSWER

I realized that the app.system.callSystem() does actually work but without app.

So it would look like this:

system.callSystem("curl -o ~/Desktop/OLU474619.png https://static.www.nfl.com/image/private/h_100,f_auto,q_auto,c_fill,g_auto/league/jccqiejlzdigw2zwxx2n.png");

This allows me to download the cloudinary image to a specific directory with simplicity.

1
Aditi Madan On

You can simply add fl_attachment in the URL to download the image: https://static.www.nfl.com/image/private/h_100,f_auto,q_auto,c_fill,g_auto,fl_attachment/league/jccqiejlzdigw2zwxx2n

If doing programmatically then pass it as a flag("attachment") in the transformation. For your case, the first option should do.