tanaike - Google Apps Script, Gemini API, and Developer Tips

The Thinker

Resumable Upload of Multiple Files with Asynchronous Process for Google Drive

Overview

This is a sample script for uploading multiple files with large size (> 50 MB) at the sidebar, dialog of Google Docs and Web Apps using the resumable upload of the asynchronous process with Javascript and Google Apps Script (GAS).

Demo

This is a demonstration of this script. As a demonstration, it uploads 5 files with the size of 100 MB to own Google Drive. When the files were selected and the upload button is clicked, those are uploaded by the resumable upload with the asynchronous process. It is found that the files can be completely uploaded with the asynchronous process. In this demo, as a test case, the chunk size of 20 MB was used.

Javascript library - ResumableUploadForGoogleDrive_js

Overview

This is a Javascript library to achieve the resumable upload for Google Drive.

Description

When a file more than 5 MB is uploaded to Google Drive with Drive API, the resumable upload is required to be used. I have already published the sample script for “Resumable Upload for Web Apps using Google Apps Script”. Ref In this case, Web Apps is used. Here, I would like to introduce the script for the resumable upload created by only Javascript. Unfortunately, in the current stage, at google-api-javascript-client, there are no methods for the resumable upload. And, I thought that when this function is created as a Javascript library, it might be useful for users. Also that library is also useful for me. So I created this. If this was useful for your situation, I’m glad.

One Time Download for Google Drive

Overview

This is a sample script for downloading files from Google Drive by the one time download method.

Description

When you download a file from Google Drive, in generally, the login and the access token are required. If you want to download the file without the authorization for the simple situation, the file is required to be publicly shared. But the file might not be able to be shared publicly, because of various reasons.

Modifying Revisions of a File on Google Drive using Google Apps Script

Gists

This is a sample script for modifying the revisions of a file on Google Drive using Google Apps Script. This script can be used for not only Google Docs files, but also the files except for Google Docs.

Issue and workaround:

Unfortunately, in the current stage, at Google Docs files, the revision of Google Docs cannot be directly changed by APIs with a script. So as one of several workarounds, I would like to propose to overwrite the Google Docs file using the exported data. On the other hand, at the files except for Google Docs, the data can be directly retrieved with the revision ID. This can be used for overwriting the file. The flow of this script is as follows.

Javascript library - syncGoogleScriptRun

Overview

This is a Javascript library to use “google.script.run” with the synchronous process.

Description

When I create Web Apps, add-on using a side bar and dialog, there is the case that I want to use google.script.run with the synchronous process. As you know, google.script.run works with the asynchronous process. So in order to use it as the synchronous process, the script is required to be prepared. I also saw several issues for such situation at Stackoverflow and other sites. I thought that when the script for achieving this was prepared as a library, it might be useful for users. So I created this.

Javascript library - GetFileList_js

Overview

This is a Javascript library to retrieve the file list with the folder tree from the specific folder (publicly shared folders and own folders) of Google Drive.

Description

The library for retrieving the file list with the folder tree from the specific folder of Google Drive has already been published for Google Apps Script, golang, node.js and python as GetFileList. Ref Here, this GetFileList was released as the library of Javascript.

Benchmark: Importing CSV Data to Spreadsheet using Google Apps Script

Gists

August 28, 2019 Published.

Kanshi Tanaike

Introduction

Please be careful! This result can be only used for Google Apps Script.

There are a limit executing time for Google Apps Script (GAS). That is 6 minutes for Consumer and Google Apps free edition, and 30 minutes for G Suite and Early Access. 1 So many users always have to pay attention to reducing the process cost of scripts. So it is very important to know the process cost of various situations. I have already reported the costs for various processes as the reports. 2 In this report, the process cost for importing CSV data to Spreadsheet using GAS has been investigated.

Running Functions by Specifying Function Names with Web Apps for Google Apps Script

Gists

In this report, I would like to introduce the method for running functions by directly specifying the function names with Web Apps for Google Apps Script.

Description

It has already been known that the directly specified functions in the project can be run from the outside by enabling “API executable” and using the method of scripts.run in Google Apps Script API. In this case, the installation for using Apps Script API is a bit complicate. I think that this is making users difficult to use Apps Script API, although the important settings are including in the installation when the importance of the security is considered. As one of workarounds for making easy to run the directly specified functions in the project, I would like to introduce the method using Web Apps. When Web Apps is accessed, the functions of doGet() and doPost() are used. These are the reserved function name. But, when this method is used, the functions in the project can be run by directly selecting from the outside.