Dropbox Java Api上传文件

时间:2016-09-06 08:55:55

标签: dropbox dropbox-api dropbox-java

如何公开上传文件并获取链接?我正在使用Dropbox Java核心API。 Here

  public static void Yukle(File file) throws DbxException, IOException {
    FileInputStream fileInputStream = new FileInputStream(file);
    InputStream inputStream = fileInputStream;
    try (InputStream in = new FileInputStream(file)) {
        UploadBuilder metadata = clientV2.files().uploadBuilder("/"+file.getName());
        metadata.withMode(WriteMode.OVERWRITE);
        metadata.withClientModified(new Date());
        metadata.withAutorename(false);
        metadata.uploadAndFinish(in);
        System.out.println(clientV2.files());
    }
}

1 个答案:

答案 0 :(得分:0)

我使用以下代码将文件上传到DropBox:

var thumbs = document.getElementsByClassName("thumb");

for (var i = 0; i < thumbs.length; i++) {
    thumbs[i].addEventListener("click", showBigImage);
}

function showBigImage() {
    if (this.className.indexOf("active") > -1) {
        this.className = this.className.replace(" active", "");
    }
    else {
        this.className = this.className + " active";
    }
}