Last active
October 19, 2020 02:53
-
-
Save simonfongnt/39e310b03c37700271553f8d9dd4d480 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
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