[英]Dropbox API Android
This question would be related mostly to Android, however it is a little more general. 这个问题主要与Android有关,但是有点普遍。
I can upload and download files using getFile
and such API calls, however, I am trying to access a directory which exists already on Dropbox and list it's content. 我可以使用getFile
和此类API调用上载和下载文件,但是,我试图访问Dropbox上已经存在的目录并列出其内容。
Using the API, I would like to be able to reference the directory at path '/path/to/dir/' and list all the Entry
objects inside it using Entry.contents
. 使用API,我希望能够引用路径'/ path / to / dir /'的目录,并使用Entry.contents
列出其中的所有Entry
对象。
I've tried this and it doesn't work: 我已经尝试过了,但是不起作用:
Entry dir = new Entry();
dir.path = "/path/to/dir";
Log.d(TAG, "isDir ? " + Boolean.toString(dir.isDir));
for (Entry entry : dir.contents) {
Log.d(TAG, entry.filename());
}
The directory is not empty. 目录不为空。 isDir
returns false
and no filenames are printed. isDir
返回false
并且不打印文件名。
Is there a way to do this, or do I need to use the search method? 有没有办法做到这一点,或者我需要使用搜索方法吗?
All I want is the list of files in an existing directory. 我想要的只是现有目录中的文件列表。
Thanks a lot 非常感谢
This can be done with the metadata function: 这可以通过元数据功能完成:
String path2Dir = "path/to/dir";
Entry dir = mDropboxApiInstance.metadata(path2Dir, null, true, null);
List<Entry> contents = dir.contents;
for (Entry dropboxFile : contents){
// do stuff with remote file's data
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.