Box java sdk - 为 BoxItem 生成一个 Box URL
Box java sdk - generating a Box URL for a BoxItem
这是我在给定盒子项目的情况下用来生成盒子 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。否则我们没有可行的 URL 从盒子 java sdk.
获取文件时使用
这样可以吗?它有什么问题吗? SDK 中是否有某些东西可能已经完成了此功能的功能?
URL 格式已在新 Box UI 中更改(变得更好):
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());
}
}
这是我在给定盒子项目的情况下用来生成盒子 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。否则我们没有可行的 URL 从盒子 java sdk.
获取文件时使用这样可以吗?它有什么问题吗? SDK 中是否有某些东西可能已经完成了此功能的功能?
URL 格式已在新 Box UI 中更改(变得更好):
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());
}
}