正确使用Google Drive API v3来检索文件的父文件夹ID?

时间:2017-07-22 10:17:08

标签: c# .net vb.net google-api google-drive-api

SCENARIO

我正在尝试使用 Google Drive API v3 开发一个简单程序,该程序必须能够列出存储在用户“驱动器”中的所有文件,然后解释目录层次结构(这意味着:确定文件存储在哪个文件夹名称/ id中。

问题

我遇到的问题是基本上# draw the line plot using ggplot gg <-ggplot(plotbycity, aes(x = date, y = rent, group = city, color = city, text = paste('Rent ($):', rent, '<br>Date: ', as.Date(date), '<br>Obs: ', count))) + geom_line() + ggtitle("Monthly Rents") p <- ggplotly(gg, tooltip = c("text")) 属性(理论上包含文件存储位置的文件夹的ID)始终为空( nul )收到回复后,即使我确保在请求中指定File.Parents值:

用C#编写的代码:

parents

用VB.NET编写的原始代码:

using Google.Apis.Drive.v3;

private DriveService client;
// ...

FilesResource.ListRequest request = this.client.Files.List();

request.PageSize = 100;
request.SupportsTeamDrives = false;
request.Fields = "nextPageToken, files(id, name, description, size,
                                       trashed, shared, ownedByMe, isAppAuthorized,
                                       createdTime, modifiedTime, 
                                       parents)";

FileList response = await request.ExecuteAsync();

此外,另外,其他属性如Imports Google.Apis.Drive.v3 Private client As DriveService ' ... Dim request As FilesResource.ListRequest = Me.client.Files.List() With request .PageSize = 100 .SupportsTeamDrives = False .Fields = "nextPageToken, files(id, name, description, size, trashed, shared, ownedByMe, isAppAuthorized, createdTime, modifiedTime, parents)" End With Dim response As FileList = Await request.ExecuteAsync() File.CreatedTime也是如此,我不明白为什么。其他属性如File.ModifiedTimeFile.Id按预期工作......很好。

问题

为什么File.Name属性为nul,我该如何解决?我不想做什么?。

研究

Files: list

File metadata

File.Parents

1 个答案:

答案 0 :(得分:1)

尝试设置fields=*并从那里向后工作。 https://developers.google.com/drive/v3/web/performance#partial提到了通配符,尽管该页面看起来已经过时了。