I would like to download images from the web to a drive folder just by writing the image link. for example I want to download the image is in a drive folder automatically with google apps script.
https://i.imgur.com/QCFXhpg.jpg
It would be like a kind of web scraping in which I get the images of said web in a folder.
function myFunction() {
var destination_id = '1cgzNUb88ZHXSQ7iZ0zYigH1f7KD_7geH' //// Id of the folder in which we are going to store the image
var img = ...;
var destination = DriveApp.getFolderById(destination_id)
destination.createFile(img)
}
CodePudding user response:
In that case, I think that the image can be retrieved using UrlFetchApp. So in the case of your script, how about the following modification?
From:
var img = ...;
To:
var img = UrlFetchApp.fetch("https://i.imgur.com/QCFXhpg.jpg").getBlob();