gpt4 book ai didi

java - Box java sdk - 为 BoxItem 生成 Box URL

转载 作者:行者123 更新时间:2023-11-30 10:33:03 26 4
gpt4 key购买 nike

这是我用来生成给定盒子项目的盒子 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。否则,在从 java sdk 中获取文件时,我们没有可用的 URL。

这样可以吗?它有什么问题吗? SDK 中是否有某些东西可能已经完成了此功能的功能?

最佳答案

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

关于java - Box java sdk - 为 BoxItem 生成 Box URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42395818/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com