List of usage examples for com.amazonaws.event ProgressListenerChain ProgressListenerChain
public ProgressListenerChain(ProgressListener... listeners)
From source file:br.com.ingenieux.mojo.aws.util.BeanstalkerS3Client.java
License:Apache License
@Override public PutObjectResult putObject(PutObjectRequest req) throws AmazonClientException, AmazonServiceException { if (!multipartUpload) { return super.putObject(req); }//from www .j a v a 2 s. c o m final long contentLen = TransferManagerUtils.getContentLength(req); String tempFilename = req.getKey() + ".tmp"; String origFilename = req.getKey(); req.setKey(tempFilename); XProgressListener progressListener = new XProgressListener(); req.setGeneralProgressListener(new ProgressListenerChain(progressListener)); progressListener.setContentLen(contentLen); progressListener.setUpload(transferManager.upload(req)); progressListener.setSilentUpload(silentUpload); try { progressListener.getUpload().waitForCompletion(); } catch (InterruptedException e) { throw new AmazonClientException(e.getMessage(), e); } CopyObjectRequest copyReq = new CopyObjectRequest(req.getBucketName(), tempFilename, req.getBucketName(), origFilename); copyObject(copyReq); deleteObject(new DeleteObjectRequest(req.getBucketName(), tempFilename)); return null; }