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.