List of usage examples for com.amazonaws.services.s3.model DeleteObjectRequest withGeneralProgressListener
public <T extends AmazonWebServiceRequest> T withGeneralProgressListener(ProgressListener progressListener)
From source file:modules.storage.AmazonS3Storage.java
License:Open Source License
@Override public F.Promise<Void> delete(String key, String name) { Promise<Void> promise = Futures.promise(); AmazonS3 amazonS3 = new AmazonS3Client(credentials); DeleteObjectRequest request = new DeleteObjectRequest(bucketName, key); request.withGeneralProgressListener(progressEvent -> { if (progressEvent.getEventType().isTransferEvent()) { if (progressEvent.getEventType().equals(ProgressEventType.TRANSFER_COMPLETED_EVENT)) { promise.success(null);/* w ww.ja v a 2s . c om*/ } else if (progressEvent.getEventType().equals(ProgressEventType.TRANSFER_FAILED_EVENT)) { logger.error(progressEvent.toString()); promise.failure(new Exception(progressEvent.toString())); } } }); try { amazonS3.deleteObject(request); } catch (AmazonServiceException ase) { logAmazonServiceException(ase); } catch (AmazonClientException ace) { logAmazonClientException(ace); } return F.Promise.wrap(promise.future()); }