在我的应用程序中,我试图列出位于Google云端硬盘某个文件夹中的所有文件。我想让用户能够选择任何文件以将其上传到我的服务器。我使用以下功能来实现此目的。
private func listFiles(_ folderID: String, onCompleted: @escaping (GTLRDrive_FileList?, Error?) -> ()) {
let query = GTLRDriveQuery_FilesList.query()
query.pageSize = 100
query.q = "'\(folderID)' in parents"
query.fields = "kind,nextPageToken,files(mimeType,id,kind,name,webViewLink,thumbnailLink,trashed,parents)"
service.shouldFetchNextPages = true
service.executeQuery(query) { (ticket, result, error) in
print(ticket)
print(result)
onCompleted(result as? GTLRDrive_FileList, error)
}
}
但是结果始终是0 files
,以下是关于shouldFetchNextPages
的内容:
Executing GTLRDriveQuery_FilesList has additional pages of results not fetched because shouldFetchNextPages is not enabled
这是退回机票的结果:
{service:<GTLRDriveService: 0x600000b6df80> fetcher:GTMSessionFetcher 0x7f86fef07140 (https://www.googleapis.com/drive/v3/files?fields=kind%2CnextPageToken%2Cfiles%28mimeType%2Cid%2Ckind%2Cname%2CwebViewLink%2CthumbnailLink%2Ctrashed%2Cparents%29&pageSize=100&prettyPrint=false&q=%271HRw9oP6qGCyKxlnIIap_IdhcRcd72YCG%27%20in%20parents) }
这是返回结果的结果:
Optional(GTLRDrive_FileList 0x6000030c7d20: {kind:"drive#fileList" files:[0]})
有什么主意吗?