简体   繁体   中英

How to get upload progress with Java SDK for Dropbox API v2?

I have searched the Dropbox documentation on its Developers page and on Stack Overflow, and I haven't found a way to get the upload progress of a file in the Java SDK for API v2. I don't have idea how to get the upload progress. Could someone help me with this?

I tried with ProgresMonitorInputStream , but it only tells me the progress of reading the file, it does not indicate the upload progress to the Dropbox server.

DbxRequestConfig config = DbxRequestConfig.newBuilder("My App/1.0.0").build();
DbxClientV2 client = new DbxClientV2(config, Constants.ACCESS_TOKEN);

    FileMetadata metadata;

    try {
        try (InputStream in = new FileInputStream(filepath)) {

            InputStream progressMonitorInputStream = new ProgressMonitorInputStream(null, "Uploading...", in);

            metadata = client.files()
                    .uploadBuilder("/test.exe")
                    .withMode(WriteMode.OVERWRITE)
                    .uploadAndFinish(progressMonitorInputStream);
        }

    } catch (DbxException | IOException e) {
        e.printStackTrace(System.err);
        return;
    }

I want the upload progress to show it in a JProgressBar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM