Google Drive API V3 (javascript) update file contents

后端 未结 3 588
灰色年华
灰色年华 2021-01-04 05:28

I want to update the contents of a Google doc using the Google Drive API V3 (javascript):

https://developers.google.com/drive/v3/reference/files/update

I\'m

3条回答
  •  半阙折子戏
    2021-01-04 06:04

    Yo you can do this with fetch using the node-js google API, assuming you stored your token(s) already in a var named tokens:

    fetch("https://www.googleapis.com/upload/drive/v3/files/ID_OF_DRIVE_FILE?uploadType=media",
            {   
                headers: {
                    'Content-Type':'multipart/related; boundary=a5cb0afb-f447-48a6-b26f-328b7ebd314c',
                    'Accept-Encoding': 'gzip',
                    'User-Agent': 'google-api-nodejs-client/0.7.2 (gzip)',
                    Authorization:tokens.token_type +" "+ tokens.access_token,
                    Accept:"application/json"
                },
                method:"PATCH",
                body: "OK now iasdfsdgeaegwats AGAIN intresting",
                cb(r) {
    
                }
            }).then(r => {
                console.log(r);
            });
    

提交回复
热议问题