Skip to content

Instantly share code, notes, and snippets.

@simonfongnt
Last active October 19, 2020 02:53
Show Gist options
  • Save simonfongnt/39e310b03c37700271553f8d9dd4d480 to your computer and use it in GitHub Desktop.
Save simonfongnt/39e310b03c37700271553f8d9dd4d480 to your computer and use it in GitHub Desktop.
Drive API Write File Javascript
const DriveRenameUrl = 'https://content.googleapis.com/drive/v3/files/';
// rename file - fetch
fetch(
DriveRenameUrl + fileId + '?alt=json',
{
method: 'PATCH',
headers: {
Authorization: 'Bearer ' + token,
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
'name': FilenameString
})
}
).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