public static void uploadToS3(TransferManager transferManager, final File file, final FileProgressListener fileProgressListener) throws InterruptedException { PutObjectRequest putObjectRequest = new PutObjectRequest("car-classifieds", file.getName(), file) .withCannedAcl(CannedAccessControlList.PublicRead); final Upload upload = transferManager.upload(putObjectRequest); upload.addProgressListener(new ProgressListener() { @Override public void progressChanged(ProgressEvent progressEvent) { fileProgressListener.onProgressChanged(progressEvent.getBytesTransferred()); if (progressEvent.getEventCode() == ProgressEvent.COMPLETED_EVENT_CODE) { fileProgressListener.onCompleteUpload(); } if (progressEvent.getEventCode() == com.amazonaws.event.ProgressEvent.STARTED_EVENT_CODE) { fileProgressListener.onStartUpload(); } if (progressEvent.getEventCode() == com.amazonaws.event.ProgressEvent.FAILED_EVENT_CODE) { fileProgressListener.onFailedUpload(); } } }); }
public static void uploadToS3(TransferManager transferManager, final File file) throws InterruptedException { PutObjectRequest putObjectRequest = new PutObjectRequest("car-classifieds", file.getName(), file) .withCannedAcl(CannedAccessControlList.PublicRead); final Upload upload = transferManager.upload(putObjectRequest); upload.addProgressListener(new ProgressListener() { @Override public void progressChanged(ProgressEvent progressEvent) { if (progressEvent.getEventCode() == ProgressEvent.COMPLETED_EVENT_CODE) { } } }); }