对于v2版本,我们可以通过Google Drive API获得重命名文件的示例。以下是链接:
https://developers.google.com/drive/api/v2/reference/files/patch#examples
以下是如何在JavaScript中使用v2重命名文件的方法。
/**
* Rename a file.
*
* @param {String} fileId <span style="font-size: 13px; ">ID of the file to rename.</span><br> * @param {String} newTitle New title for the file.
*/
function renameFile(fileId, newTitle) {
var body = {'title': newTitle};
var request = gapi.client.drive.files.patch({
'fileId': fileId,
'resource': body
});
request.execute(function(resp) {
console.log('New Title: ' + resp.title);
});
}
我需要使用Electron和Node.js创建类似于V2示例的函数。目前为止,我已经完成了以下工作:mfm-gdrive。