Resumable Upload for Web Apps using Google Apps Script



This is a sample script for uploading files with large size (> 50 MB) at Web Apps using Google Apps Script (GAS). The resumable upload method is used for uploading files. This script can be also applied to the script using gapi of javascript.


This is a demonstration of this script. As a demonstration, it uploads a file with the size of 100 MB to my Google Drive. When the file was selected, it is uploaded by the resumable upload. It is found that the file can be completely uploaded.


Have you ever thought that you want to upload files with large size from local PC at Web Apps using GAS? Recently, I have thought it. So I investigated about this situation. At first, it was found that there are some limitations for uploading files to Google Drive from local PC.

  1. When “uploadType” is used as “media” and “multipart”, the limitation of size is less than 5 MB (5,242,880 bytes).
    • This is the specification of Drive API.
  2. When “” is used, the limitation of size if less than 50 MB (52,428,800 bytes).
    • This is the specification of “DriveApp.createFile(blob)”.
    • “blob” can be used for the size more than 50 MB. But a file cannot be created using “DriveApp.createFile(blob)”. Furthermore, “blob” with the size more than 50 MB cannot be converted to the byte array.
      • This is due to my experiments.

When users want to upload files with the size more than 50 MB to Google Drive, the Resumable Upload is required to be used. As the next step, although I have looked for the sample script, Unfortunately, I couldn’t find it. So I created this. The flow of this sample script is as follows.

  1. Retrieve a file.
  2. Retrieve an access token from GAS.
    • In this sample script, GAS is mainly used for retrieving the access token.
  3. Retrieve the endpoint for the resumable upload using the access token.
  4. Upload chunks for the resumable upload to the endpoint.

If this was useful for you, I’m glad.

You can check this at