GAS Library - DownloadLargeFilesByUrl

Overview

DownloadLargeFilesByUrl is a GAS library for downloading large files from URL to Google Drive using Google Apps Script (GAS).

Description

I had been thinking of about whether a large file from an URL can be downloaded to Google Drive using GAS. When I have tried to download such large files, I noticed the following limitations. These limitations are due to the specification of GAS.

When it tries to create the application for downloading the large files, it is required to consider above limitations. On the other hand, there are the following relaxations of quotas by the recent Google’s update.

From these limitations and relaxed quotas, I could notice a direction for achieving it. I came up with the following flow.

  1. When a large file is download from URL, the file is downloaded by splitting using the range to the header.
  2. Use fetchAll method to download the file. Downloading is run by the asynchronous processing.
  3. Use resumable upload to join the split data to the original file. Joining is run by the synchronous processing. Because the resumable upload has to be done by the synchronous processing.

I could create this library using the flow like this. If this was useful for you, I’m glad.

You can check this at https://github.com/tanaikech/DownloadLargeFilesByUrl.

 Share!