![](/img/trans.png)
[英]JavaScript Google Drive API V3 - Upload a file to a folder
[英]Google DRIVE API V3 - Get a root folder ID with nodejs
我需要獲取根文件夾ID和過濾器文件夾,其中根文件夾作為其父文件夾。 使用Nodejs和google drive API v3。 這是我的代碼以及如何更改此代碼以獲取root folderId?
const service = google.drive('v3'); service.files.list({ auth: client2, fields: 'nextPageToken, files(id, name, webContentLink, webViewLink, mimeType, parents)' }, (err, res) => { if (err) { console.error('The API returned an error.'); throw err; } const files = res.data.files; if (files.length === 0) { console.log('No files found.'); } else { console.log('Files Found!'); for (const file of files) { console.log(`${file.name} (${file.id})`); }
根文件夾的文件夾ID是“root”。 file.list方法有一個名為q的選項參數,用於搜索。
service.files.list({auth: auth,
resource: { parents: [ folderId ] },
q: "'root' in parents",
fields: '*',
spaces: 'drive',
pageToken: pageToken,
}
這段代碼是一種猜測,因為我沒有權力在這台機器上測試節點。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.