这是我用来生成一个盒子URL给定一个盒子项目。
private String generateURL(BoxItem item) {
if (item instanceof BoxFolder) {
if (item.getInfo().getParent() == null) {
return "https://app.box.com/files/0";
} else {
return String.format("https://app.box.com/files/0/f/%s", item.getInfo().getParent().getID());
}
} else {
return String.format(
"https://app.box.com/files/0/f/%s/1/f_%s", item.getInfo().getParent().getID(), item.getID());
}
}我在没有盒子项目的共享URL时生成此URL。否则,在从box java sdk获取文件时,我们就没有可用的URL可用了。
这样可以吗?有什么问题吗?SDK中有没有什么东西可能已经完成了这个函数的功能?
发布于 2017-02-23 00:23:29
在新的Box UI中,URL格式已更改(变得更好):
private String generateURL(BoxItem item) {
if (item instanceof BoxFolder) {
if (item.getInfo().getParent() == null) {
return "https://app.box.com/folder/0";
} else {
return String.format("https://app.box.com/folder/%s", item.getInfo().getParent().getID());
}
} else {
return String.format("https://app.box.com/file/%s", item.getID());
}
}https://stackoverflow.com/questions/42395818
复制相似问题