【问题标题】:Dropbox API AndroidDropbox API Android
【发布时间】:2012-07-18 14:37:39
【问题描述】:

这个问题主要与 Android 相关,但更笼统一些。

我可以使用getFile 和此类 API 调用上传和下载文件,但是,我正在尝试访问 Dropbox 上已经存在的目录并列出其内容。

使用 API,我希望能够引用路径 '/path/to/dir/' 处的目录,并使用 Entry.contents 列出其中的所有 Entry 对象。

这个我试过了,还是不行:

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());
}

目录不为空。 isDir 返回 false 并且不打印文件名。

有没有办法做到这一点,还是我需要使用搜索方法?

我想要的只是现有目录中的文件列表。

非常感谢

【问题讨论】:

    标签: android dropbox dropbox-api dropbox-entry


    【解决方案1】:

    这可以通过元数据函数来完成:

    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
    }
    

    【讨论】:

      猜你喜欢
      • 2016-08-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多