[Google Apps Script] Download an image and save it to Google Drive

Created on November 30, 2026

You can use UrlFetchApp.fetch() to download an image, then pass the response as a blob to createFile() on a Drive folder.

function saveImageToDrive() {
  const response = UrlFetchApp.fetch("https://example.com/chart.png");
  const image = response.getBlob().setName("chart.png");
  const folder = DriveApp.getFolderById("YOUR_DRIVE_FOLDER_ID");
  const file = folder.createFile(image);
  console.log(file.getName());
}

Replace the example URL with a reachable image URL and use the ID of a Drive folder you can edit. getBlob() preserves the downloaded bytes, and setName() sets the name of the saved file.

Google Apps Script