@Override public F.Promise<Void> delete(String key) { 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); } else if (progressEvent .getEventType() .equals(ProgressEventType.TRANSFER_FAILED_EVENT)) { promise.failure(new Exception("Delete failed")); } } }); amazonS3.deleteObject(request); return F.Promise.wrap(promise.future()); }
/** * Creates a delete request to delete an instruction file in S3. * * @param request The delete request for the original object to be deleted from S3. * @return A delete request to delete an instruction file in S3. * @deprecated no longer used and will be removed in the future */ @Deprecated public static DeleteObjectRequest createInstructionDeleteObjectRequest( DeleteObjectRequest request) { return new DeleteObjectRequest(request.getBucketName(), request.getKey() + INSTRUCTION_SUFFIX); }