在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();

最佳答案

您必须首先创建链接,它不会自动创建。查看此答案的操作方法:How to create shared link in box using java sdk

10-08 13:08