Last active
October 19, 2020 02:53
-
-
Save simonfongnt/0e276400c0660899c69315aecd5f46a8 to your computer and use it in GitHub Desktop.
Drive API Write File Javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var DriveBaseUrl = 'https://www.googleapis.com/'; | |
var DriveWriteUrl = 'upload/drive/v3/files/'; | |
// write file - update with Array Buffer | |
fetch( | |
DriveBaseUrl + DriveWriteUrl + fileId, | |
{ | |
method: 'PATCH', | |
headers: { | |
Authorization: 'Bearer ' + token, | |
'Accept': 'text/plain', | |
'Content-Type': 'text/plain' | |
}, | |
body: ContentArrayBuffer | |
} | |
).then(response => response.text() | |
).then(function(respText) { | |
console.log(respText); | |
}).catch(function(error) { | |
console.log(error); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment