是否可以从 Dropbox 文件的元数据中检索标签。?
Is it Possible to retrieve the just the Tag from Metadata of Dropbox File.?
我正在尝试检索 Dropbox 元数据的标签,以便我可以将其保存在列表中并使用它来显示给定数据是文件、文件夹类型还是已删除?
这是我正在使用的方法 withIncludedDeleted 它允许我显示所有已删除的 File/Folder 和未删除的 File/Folder 以及显示标签,如果它被删除或没有。
ListFolderBuilder EntrylistFolderBuilder = getDbxCleint().files().listFolderBuilder("/data/entries");
ListFolderResult result = EntrylistFolderBuilder.withRecursive(true).withIncludeDeleted(true).start();
while (true) {
for (Metadata metadata : result.getEntries()) {
mEntries.add(metadata);
//--------//
}
if (!result.getHasMore()) {
break;
}
result = getDbxCleint().files().listFolderContinue(result.getCursor());
}
}
是否可以只从元数据中检索标签?因为我不想写一个看起来非常相似的不同方法,一个带有 Include Delete,另一个没有它,只是两个打印两个列表。
这是存储在 mEntries ArrayList 中的元数据的样子-
{".tag":"folder","name":"entries","id":"id:NNgoZ4mypJAAAAAAAAABCw","path_lower":"/data/entries","path_display":"/data/entries"}
{".tag":"deleted","name":"entry_87e7c498a6631825dd3aa5a3c810c49a","path_lower":"/data/entries/entry_87e7c498a6631825dd3aa5a3c810c49a","path_display":"/data/entries/entry_87e7c498a6631825dd3aa5a3c810c49a"}
{".tag":"file","name":"entry_0d08beeee44681783e76de22fdfa9cb1","id":"id:NNgoZ4mypJAAAAAAAAAA_g","client_modified":"2019-03-04T10:11:44Z","server_modified":"2019-03-04T10:11:45Z","rev":"017000000012d1542b0","size":389,"path_lower":"/data/entries/entry_0d08beeee44681783e76de22fdfa9cb1","path_display":"/data/entries/entry_0d08beeee44681783e76de22fdfa9cb1","content_hash":"b05a1ceebccebd2d85520b944b56ddb7edefc7823a129a9bc116d60bbc9227a7"}
{".tag":"file","name":"entry_48b6afc3a21d255ef0cbe3ec758be441","id":"id:NNgoZ4mypJAAAAAAAAAA_w","client_modified":"2019-03-04T10:11:44Z","server_modified":"2019-03-04T10:11:45Z","rev":"018000000012d1542b0","size":2010,"path_lower":"/data/entries/entry_48b6afc3a21d255ef0cbe3ec758be441","path_display":"/data/entries/entry_48b6afc3a21d255ef0cbe3ec758be441","content_hash":"5c94187209c748e22a38926fddbbf860460e14fee1f3d76f9e81aefc446a6612"}
像您一样使用 Dropbox SDK 时,您不需要直接与 JSON 交互(例如,获取“.tag.”值)。 SDK 会为您将这些对象转换为本机类型化对象。您可以检查对象的类型以根据需要处理它们。您可以使用 instanceof
检查类型。
有an example of using it here. In your case, in addition to checking if it's a FileMetadata
or FolderMetadata
, you can check if it's a DeletedMetadata
. (All three of these are subclasses of Metadata
.)
我正在尝试检索 Dropbox 元数据的标签,以便我可以将其保存在列表中并使用它来显示给定数据是文件、文件夹类型还是已删除?
这是我正在使用的方法 withIncludedDeleted 它允许我显示所有已删除的 File/Folder 和未删除的 File/Folder 以及显示标签,如果它被删除或没有。
ListFolderBuilder EntrylistFolderBuilder = getDbxCleint().files().listFolderBuilder("/data/entries");
ListFolderResult result = EntrylistFolderBuilder.withRecursive(true).withIncludeDeleted(true).start();
while (true) {
for (Metadata metadata : result.getEntries()) {
mEntries.add(metadata);
//--------//
}
if (!result.getHasMore()) {
break;
}
result = getDbxCleint().files().listFolderContinue(result.getCursor());
}
}
是否可以只从元数据中检索标签?因为我不想写一个看起来非常相似的不同方法,一个带有 Include Delete,另一个没有它,只是两个打印两个列表。
这是存储在 mEntries ArrayList 中的元数据的样子-
{".tag":"folder","name":"entries","id":"id:NNgoZ4mypJAAAAAAAAABCw","path_lower":"/data/entries","path_display":"/data/entries"}
{".tag":"deleted","name":"entry_87e7c498a6631825dd3aa5a3c810c49a","path_lower":"/data/entries/entry_87e7c498a6631825dd3aa5a3c810c49a","path_display":"/data/entries/entry_87e7c498a6631825dd3aa5a3c810c49a"}
{".tag":"file","name":"entry_0d08beeee44681783e76de22fdfa9cb1","id":"id:NNgoZ4mypJAAAAAAAAAA_g","client_modified":"2019-03-04T10:11:44Z","server_modified":"2019-03-04T10:11:45Z","rev":"017000000012d1542b0","size":389,"path_lower":"/data/entries/entry_0d08beeee44681783e76de22fdfa9cb1","path_display":"/data/entries/entry_0d08beeee44681783e76de22fdfa9cb1","content_hash":"b05a1ceebccebd2d85520b944b56ddb7edefc7823a129a9bc116d60bbc9227a7"}
{".tag":"file","name":"entry_48b6afc3a21d255ef0cbe3ec758be441","id":"id:NNgoZ4mypJAAAAAAAAAA_w","client_modified":"2019-03-04T10:11:44Z","server_modified":"2019-03-04T10:11:45Z","rev":"018000000012d1542b0","size":2010,"path_lower":"/data/entries/entry_48b6afc3a21d255ef0cbe3ec758be441","path_display":"/data/entries/entry_48b6afc3a21d255ef0cbe3ec758be441","content_hash":"5c94187209c748e22a38926fddbbf860460e14fee1f3d76f9e81aefc446a6612"}
像您一样使用 Dropbox SDK 时,您不需要直接与 JSON 交互(例如,获取“.tag.”值)。 SDK 会为您将这些对象转换为本机类型化对象。您可以检查对象的类型以根据需要处理它们。您可以使用 instanceof
检查类型。
有an example of using it here. In your case, in addition to checking if it's a FileMetadata
or FolderMetadata
, you can check if it's a DeletedMetadata
. (All three of these are subclasses of Metadata
.)