【发布时间】:2019-05-23 08:41:10
【问题描述】:
我终于让 Google Drive API V3 与服务帐户一起使用。
现在要从驱动器中检索所有文件,我使用以下命令:
$optParams = [
'corpora' => 'drive',
'driveId' => env('GOOGLE_DRIVE_ID'),
'includeItemsFromAllDrives' => true,
'supportsAllDrives' => true,
'fields' => 'files(name,mimeType,trashed,parents,version,webContentLink,webViewLink,createdTime,modifiedTime,size)'
];
$this->googleDrive->files->listFiles($optParams);
所以我特别要求文件数组中的某些字段。问题是,所有其他字段仍然存在(除了它们都是 null 值)。这是正常的行为吗?因为如果我尝试检索 20 到 50 个文件,但仍有一些无用的 Kb 正在传输。
响应示例:
+"files": array:2 [▼
0 => Google_Service_Drive_DriveFile {#279 ▼
#collection_key: "spaces"
+appProperties: null
#capabilitiesType: "Google_Service_Drive_DriveFileCapabilities"
#capabilitiesDataType: ""
#contentHintsType: "Google_Service_Drive_DriveFileContentHints"
#contentHintsDataType: ""
+copyRequiresWriterPermission: null
+createdTime: "2019-05-22T11:41:25.852Z"
+description: null
+driveId: null
+explicitlyTrashed: null
+exportLinks: null
+fileExtension: null
+folderColorRgb: null
+fullFileExtension: null
+hasAugmentedPermissions: null
+hasThumbnail: null
+headRevisionId: null
+iconLink: null
+id: null
#imageMediaMetadataType: "Google_Service_Drive_DriveFileImageMediaMetadata"
#imageMediaMetadataDataType: ""
+isAppAuthorized: null
+kind: null
#lastModifyingUserType: "Google_Service_Drive_User"
#lastModifyingUserDataType: ""
+md5Checksum: null
+mimeType: "application/zip"
+modifiedByMe: null
+modifiedByMeTime: null
+modifiedTime: "2019-05-22T11:41:25.852Z"
+name: "<something>"
+originalFilename: null
+ownedByMe: null
#ownersType: "Google_Service_Drive_User"
#ownersDataType: "array"
+parents: array:1 [▶]
+permissionIds: null
#permissionsType: "Google_Service_Drive_Permission"
#permissionsDataType: "array"
+properties: null
+quotaBytesUsed: null
+shared: null
+sharedWithMeTime: null
#sharingUserType: "Google_Service_Drive_User"
#sharingUserDataType: ""
+size: "455778"
+spaces: null
+starred: null
+teamDriveId: null
+thumbnailLink: null
+thumbnailVersion: null
+trashed: false
+trashedTime: null
#trashingUserType: "Google_Service_Drive_User"
#trashingUserDataType: ""
+version: "2"
#videoMediaMetadataType: "Google_Service_Drive_DriveFileVideoMediaMetadata"
#videoMediaMetadataDataType: ""
+viewedByMe: null
+viewedByMeTime: null
+viewersCanCopyContent: null
+webContentLink: "<something>"
+webViewLink: "<something>"
+writersCanShare: null
#internal_gapi_mappings: []
#modelData: []
#processed: []
}
1 => Google_Service_Drive_DriveFile {#269 ▶}
【问题讨论】:
标签: laravel google-api google-drive-api google-api-php-client