実際、Google ドライブ SDK を iOS アプリに統合しました。Google ドライブ ios sdk を使用して、Google ドライブ内のファイルを取得/アップロードできます。しかし、指定された親フォルダーからファイル リストを取得するには、非常に時間がかかります。
ここで、私が使用していた手順とコードを示します。
最初に、指定された親フォルダーの子を取得してから、各子のGTLDriveChildReferenceを取得してから、子参照識別子を使用してクエリを実行しています。
これは私にとって大きなプロセスです。また、毎回Googleサーバーをリクエストします。クエリで親フォルダーIDを渡し、その親フォルダーからファイルをプルするだけのより良い方法があります。
-(void)getFileListFromSpecifiedParentFolder {
GTLQueryDrive *query2 = [GTLQueryDrive queryForChildrenListWithFolderId:<some_id or root>];
query2.maxResults = 1000;
// queryTicket can be used to track the status of the request.
[self.driveService executeQuery:query2
completionHandler:^(GTLServiceTicket *ticket,
GTLDriveChildList *children, NSError *error) {
NSLog(@"\nGoogle Drive: file count in the folder: %d", children.items.count);
//incase there is no files under this folder then we can avoid the fetching process
if (!children.items.count) {
return ;
}
if (error == nil) {
for (GTLDriveChildReference *child in children) {
GTLQuery *query = [GTLQueryDrive queryForFilesGetWithFileId:child.identifier];
// queryTicket can be used to track the status of the request.
[self.driveService executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
GTLDriveFile *file,
NSError *error) {
NSLog(@"\nfile name = %@", file.originalFilename);
}];
}
}
}];
}
いただければ幸いです。