【发布时间】:2020-03-26 10:04:10
【问题描述】:
我正在尝试通过 nodejs 使用驱动器 API v3 将谷歌文档上传到共享驱动器。进行上传的用户对将文件复制到的目标文件夹具有写入和编辑权限,并且所有 OAuth 都已设置等...但是,我收到以下错误:
domain: 'global',
reason: 'notFound',
message: 'File not found: 1BPRlu4tWhsjsRp8tjQKL59o5apWkPa0k.',
locationType: 'parameter',
location: 'fileId' } ] }
有没有办法专门针对共享驱动器?
function listFiles(auth) {
const drive = google.drive({version: 'v3', auth});
drive.files.list({
q: "mimeType = 'application/msword'",
pageSize: 100,
fields: 'nextPageToken, files(id, name)',
}, (err, res) => {
if (err) return console.log('The API returned an error: ' + err);
const files = res.data.files;
if (files.length) {
console.log('Files:');
files.map((file) => {
console.log(`${file.name} (${file.id})`);
drive.files.copy({
fileId: file.id,
'name' : 'Updated File Name',
'mimeType' : 'application/vnd.google-apps.document'
'parents': ['1BPRlu4tWhsjsRp8tjQKL59o5apWkPa0k']
})
});
} else {
console.log('No files found.');
}
});
}
【问题讨论】:
-
1BPRlu4tWhsjsRp8tjQKL59o5apWkPa0k
标签: node.js google-drive-api google-docs