Gists
This is a sample script for opening a site with new window using Google Apps Script. It is possible to open the site inside the opened dialog box using iframe. But in my situation, I had to open the site as new window. So I created this. As a sample application, it can think of like this. When the special keyword was inputted, open sites and files in Google Drive as a help window.
At February 15th, 2018, ShapeApp was featured as one of “4 useful add-ons launched last month”.
Gists
This is a sample script for uploading files from local PC to Google Drive using Python. In this sample, Quickstart is not used. So when you use this script, please retrieve access token.
Curl sample : curl -X POST \ -H "Authorization: Bearer ### access token ###" \ -F "metadata={name : 'sample.png', parents: ['### folder ID ###']};type=application/json;charset=UTF-8" \ -F "file=@sample.png;type=image/png" \ "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart" ]
Python sample : When above curl sample is converted to Python, it becomes as follows.
ggsrun was updated to v.1.4.1 v1.4.1 (February 9, 2018) For uploading, the resumable-upload method was added. The resumable-upload method is automatically used by the size of file. “multipart/form-data” can upload files with the size less than 5 MB. “resumable-upload” can upload files with the size more than 5 MB. The chunk for resumable-upload is 100 MB as the default. Users can also give this chunk size using an option.
Gists
This is a sample script for copying values from JSON to a struct using reflect package.
Script : package main
import (
"encoding/json"
"fmt"
"reflect"
)
type obj struct {
Key1 string `json:"k1"`
Key2 string `json:"k2"`
Key3 int64 `json:"k3"`
Key4 int `json:"k4"`
Key5 bool `json:"k5"`
}
func main() {
data := `{"k1": "v1", "k2": "v2", "k3": 1234567890, "k4": 456, "k5": true}`
d := map[string]interface{}{}
json.Unmarshal([]byte(data), &d)
obj := &obj{}
s := reflect.