Reputation: 20484
I'm trying to develop a simple program using the Google Drive API v3, that must be able to list all the files stored in the user's "drive", and then interpret the directory hierarchy (this means: determine in what folder(s) name/id the file is stored).
The problem I have is that basicaly the File.Parents
property (which in theory contains the ID of the folder(s) on where the file is stored) is always empty (nul) after I receive the response, even when I ensured to specify the parents
value in the request:
Code written in C#:
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();
Original code written in VB.NET:
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()
Also, and aditionally, other properties like File.CreatedTime
and File.ModifiedTime
are nul too, I don't understand why. Other properties like File.Id
or File.Name
works as expected... fine.
Why the File.Parents
property is nul, and how do I fix it?. What I'm missing to do?.
{
"kind": "drive#file",
"id": string,
"name": string,
"mimeType": string,
"description": string,
"starred": boolean,
"trashed": boolean,
"explicitlyTrashed": boolean,
"trashingUser": {
"kind": "drive#user",
"displayName": string,
"photoLink": string,
"me": boolean,
"permissionId": string,
"emailAddress": string
},
"trashedTime": datetime,
"parents": [
string
],
"properties": {
(key): string
},
"appProperties": {
(key): string
},
"spaces": [
string
],
"version": long,
"webContentLink": string,
"webViewLink": string,
"iconLink": string,
"hasThumbnail": boolean,
"thumbnailLink": string,
"thumbnailVersion": long,
"viewedByMe": boolean,
"viewedByMeTime": datetime,
"createdTime": datetime,
"modifiedTime": datetime,
"modifiedByMeTime": datetime,
"modifiedByMe": boolean,
"sharedWithMeTime": datetime,
"sharingUser": {
"kind": "drive#user",
"displayName": string,
"photoLink": string,
"me": boolean,
"permissionId": string,
"emailAddress": string
},
"owners": [
{
"kind": "drive#user",
"displayName": string,
"photoLink": string,
"me": boolean,
"permissionId": string,
"emailAddress": string
}
],
"teamDriveId": string,
"lastModifyingUser": {
"kind": "drive#user",
"displayName": string,
"photoLink": string,
"me": boolean,
"permissionId": string,
"emailAddress": string
},
"shared": boolean,
"ownedByMe": boolean,
"capabilities": {
"canAddChildren": boolean,
"canChangeViewersCanCopyContent": boolean,
"canComment": boolean,
"canCopy": boolean,
"canDelete": boolean,
"canDownload": boolean,
"canEdit": boolean,
"canListChildren": boolean,
"canMoveItemIntoTeamDrive": boolean,
"canMoveTeamDriveItem": boolean,
"canReadRevisions": boolean,
"canReadTeamDrive": boolean,
"canRemoveChildren": boolean,
"canRename": boolean,
"canShare": boolean,
"canTrash": boolean,
"canUntrash": boolean
},
"viewersCanCopyContent": boolean,
"writersCanShare": boolean,
"permissions": [
permissions Resource
],
"hasAugmentedPermissions": boolean,
"folderColorRgb": string,
"originalFilename": string,
"fullFileExtension": string,
"fileExtension": string,
"md5Checksum": string,
"size": long,
"quotaBytesUsed": long,
"headRevisionId": string,
"contentHints": {
"thumbnail": {
"image": bytes,
"mimeType": string
},
"indexableText": string
},
"imageMediaMetadata": {
"width": integer,
"height": integer,
"rotation": integer,
"location": {
"latitude": double,
"longitude": double,
"altitude": double
},
"time": string,
"cameraMake": string,
"cameraModel": string,
"exposureTime": float,
"aperture": float,
"flashUsed": boolean,
"focalLength": float,
"isoSpeed": integer,
"meteringMode": string,
"sensor": string,
"exposureMode": string,
"colorSpace": string,
"whiteBalance": string,
"exposureBias": float,
"maxApertureValue": float,
"subjectDistance": integer,
"lens": string
},
"videoMediaMetadata": {
"width": integer,
"height": integer,
"durationMillis": long
},
"isAppAuthorized": boolean
}
Upvotes: 1
Views: 2097
Reputation: 22316
Try setting fields=*
and work backwards from there. The wildcard is alluded to at https://developers.google.com/drive/v3/web/performance#partial, although that page looks generally out of date.
Upvotes: 1