如何在Android中使用框时获取最近上传的文件的共享链接?

时间:2018-01-03 13:53:47

标签: java hyperlink share 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 个答案:

答案 0 :(得分:0)

您必须先创建链接,不会自动创建。请参阅此答案如何操作:How to create shared link in box using java sdk