Skip to content

Instantly share code, notes, and snippets.

@simonfongnt
Last active October 19, 2020 02:53
Show Gist options
  • Save simonfongnt/0e276400c0660899c69315aecd5f46a8 to your computer and use it in GitHub Desktop.
Save simonfongnt/0e276400c0660899c69315aecd5f46a8 to your computer and use it in GitHub Desktop.
Drive API Write File Javascript
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