Darin Forbes
Darin Forbes

Reputation: 11

Use Google Script to download a file to Google Drive

I'm trying to make a script that downloads a .csv file from a link to my Google Drive, and then access the file's data. Once I know how to download and get access to the file in Drive, I can complete my script. I think I can access the file using the class DriveApp, but I still don't know how to get the file into my Google Drive without doing it manually.

Upvotes: 1

Views: 6593

Answers (1)

Amit Agarwal
Amit Agarwal

Reputation: 11268

Here's a little snippet that will help.

function saveFile() {
  var url = "http://www.ferc.gov/docs-filing/eqr/soft-tools/sample-csv/contract.txt";
  var blob = UrlFetchApp.fetch(url).getBlob();
  DriveApp.createFile(blob);
}

Upvotes: 3

Related Questions