Amazon S3 SdkClientException while Directory Uploading in Java

Ankit Singh :

I am using this code for uploading directory on S3.

TransferManager transferManager = new TransferManager(s3client);
MultipleFileUpload uploaded = transferManager.uploadDirectory(BUCKET_NAME, "DirectoryName", new File(uploadDirectory), true);

While uploading Directory to Amazon S3 bucket I get the following exception

com.amazonaws.SdkClientException: Upload canceled
    at com.amazonaws.services.s3.transfer.internal.UploadMonitor.call(UploadMonitor.java:159)
    at com.amazonaws.services.s3.transfer.internal.UploadMonitor.call(UploadMonitor.java:47)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

This exception generally occur around 10 times in 100 attempt

Note- The above code is executing in Multithreaded environment with the same s3client object

Thanks a lot!

Ankit Singh :

The Solution of above problem i encountered while doing R&D in Java Amazon Sdk. Instead of creating different TransferManager instances for every thread share the same instances with multiple threads if you are using same AmazonS3Client.

It will not cause any issue because it is thread safe object and problem was also solved.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=463633&siteId=1