Reputation: 193
So here is what I want to do: I have a URL of a PDF document. I want to store it directly into my google drive without downloading it to my hard drive first and then uploading to google drive. Does anyone know how to do this? Thanks in advance!!!
Upvotes: 1
Views: 2623
Reputation: 46812
Using urlFetch and DocsList, this is pretty straightforward and takes only 3 lines of code :
var urlOfThePdf = 'http://www.fostexinternational.com/docs/tech_support/pdfs/280_owners_manual.pdf';// an example of online pdf file
var folderName = 'GAS';// an example of folder name
function saveInDriveFolder(){
var folder = DocsList.getFolder(folderName);// get the folde
var file = UrlFetchApp.fetch(urlOfThePdf); // get the file content as blob
folder.createFile(file);//create the file directly in the folder
}
Upvotes: 4