I’m using Amazon’s provided High-Level API to upload files to Amazon S3. I use a lightly-modified version of the example provided:
public Upload uploadFile() {
transferManager = new TransferManager(new BasicAWSCredentials("KEY", "SECRETKEY"));
upload = transferManager.upload(existingBucketName, keyName, new File(filePath));
return upload;
}
Meanwhile, from another thread, I’m measuring its progress:
while (!upload.isDone()) {
System.out.println("upload prog " + upload.getProgress().getPercentTransfered() + " state " + upload.getState());
Thread.sleep(200);
}
The progress reporting itself seems to be working well, as I’m getting progress that makes sense. However, once it reaches 100%, the upload stalls. It looks a lot like the call to isDone() is blocking, as it simply will not update.
OUTPUT
upload prog 91.9009559586608 state InProgress
upload prog 95.31523296022095 state InProgress
upload prog 99.01403304524446 state InProgress
upload prog 100.0 state InProgress
upload prog 100.0 state InProgress
The percentage, once it gets to 100%, will not update again. It appears to update twice and then hang.
If I check for the existence of the file externally, using Cyberduck, it appears to have uploaded the file successfully.
From your code snippet, you don’t get any more updates because you have fallen through your loop, since
upload.isDone()is true. If you add:after the end of your loop, you will see the
Completedmessage. You probably see multiple 100% messages, because the TransferManager is waiting for the upload to complete.