[英]Drive API for Android: how to list every entry in Google Drive folder (also those not created by my app)
I'm using a Google Drive folder to backup some info from my app. 我正在使用Google云端硬盘文件夹备份我的应用中的某些信息。 I don't use App Folder since I want the user to be able to upload files to that same folder (for example, to upload a backup obtained by somebody else).
我不使用App Folder,因为我希望用户能够将文件上传到同一文件夹(例如,上传其他人获得的备份)。
The code I use is the following: 我使用的代码如下:
Query query = new Query.Builder()
.addFilter(Filters.eq(SearchableField.TITLE, backupName))
.build();
DriveApi.MetadataBufferResult result =
mDriveFolder
.queryChildren(mGoogleApiClient, query)
.await();
if (result == null || !result.getStatus().isSuccess()) {
return null;
}
MetadataBuffer buffer = result.getMetadataBuffer();
if (buffer.getCount() == 0) {
buffer.close();
return null;
}
Metadata m = buffer.get(0); //get first
This way, I can find the backup file only if it was uploaded by my app through the backup function. 这样,只有备份文件是由我的应用通过备份功能上传的,我才能找到备份文件。 If I upload to my Drive a file from my Desktop, or create a new document just for testing purposes, it is not found.
如果我从桌面上载文件到云端硬盘,或仅出于测试目的创建新文档,则找不到该文件。 (and from Drive I can correctly see all the files, either from my app or not, and I am the owner).
(通过云端硬盘,我可以正确地查看所有文件,无论是否来自我的应用程序,而我是所有者)。
So, I tried to list and log all the folder contents: 因此,我尝试列出并记录所有文件夹内容:
DriveApi.MetadataBufferResult result = mDriveFolder.listChildren(mGoogleApiClient).await();
if (result == null || !result.getStatus().isSuccess()) {
return null;
}
MetadataBuffer buffer = result.getMetadataBuffer();
for(Metadata m: buffer){
Log.d(TAG, m.getTitle()+" - "+m.getOriginalFilename());
}
and only the files uploaded by my app are logged. 并且仅记录我的应用上传的文件。
So, how can I get every content of my folder from the app, irrespective of its source? 因此,如何从应用程序获取文件夹中的所有内容,而不论其来源如何? Am I missing something?
我想念什么吗?
It is not possible with Google Drive SDK. Google云端硬盘SDK无法实现。 You should use http-requests for it.
您应该为此使用http-requests。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.