java在Android中使用box时,如何获得最近上传文件的共享链接?
在Android中使用box时,如何获得最近上传文件的共享链接
mFileApi.getCreateSharedLinkRequest(fileId).setCanDownload(true)
.setAccess(BoxSharedLink.Access.OPEN)
.toTask().addOnCompletedListener(new BoxFutureTask.OnCompletedListener<BoxFile>() {
@Override
public void onCompleted(BoxResponse<BoxFile> response) {
if (response.isSuccess()) {
BoxFile boxFile = response.getResult();
String downloadUrl = boxFile.getSharedLink().getDownloadURL();
Log.e("downloadurl", "onCompleted: " + downloadUrl);
//This return me a web link to show the Box page to download the file
} else {
Toast.makeText(MainActivity.this, "error while getting sharelink", Toast.LENGTH_SHORT).show();
}
}
}).run();
# 1 楼答案
必须首先创建链接,它不是自动创建的。看看这个答案:怎么做How to create shared link in box using java sdk