Search in sources :

Example 21 with DeleteObjectRequest

use of com.amazonaws.s3.model.DeleteObjectRequest in project stocator by CODAIT.

the class COSAPIClient method delete.

@Override
public boolean delete(String hostName, Path path, boolean recursive) throws IOException {
    String key = pathToKey(path);
    LOG.debug("Object name to delete {}. Path {}", key, path.toString());
    try {
        mClient.deleteObject(new DeleteObjectRequest(mBucket, key));
        memoryCache.removeFileStatus(path.toString());
        return true;
    } catch (AmazonServiceException e) {
        if (e.getStatusCode() != 404) {
            throw new IOException(e);
        }
    }
    LOG.warn("Delete on {} not found. Nothing to delete");
    return false;
}
Also used : DeleteObjectRequest(com.amazonaws.services.s3.model.DeleteObjectRequest) AmazonServiceException(com.amazonaws.AmazonServiceException) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException)

Example 22 with DeleteObjectRequest

use of com.amazonaws.s3.model.DeleteObjectRequest in project aws-sdk-java-v2 by aws.

the class S3WithUrlHttpClientIntegrationTest method deleteObject.

private static void deleteObject(String bucket, String key) {
    DeleteObjectRequest deleteObjectRequest = DeleteObjectRequest.builder().bucket(bucket).key(key).build();
    s3.deleteObject(deleteObjectRequest);
}
Also used : DeleteObjectRequest(software.amazon.awssdk.services.s3.model.DeleteObjectRequest)

Example 23 with DeleteObjectRequest

use of com.amazonaws.s3.model.DeleteObjectRequest in project Insights by CognizantOneDevOps.

the class LambdaFunctionHandler method deleteObject.

/**
 * Delete the S3 Object (S3 file)
 * @param deleteKey
 */
public void deleteObject(S3Object deleteKey) {
    try {
        DeleteObjectRequest deleteObjectRequest = DeleteObjectRequest.builder().bucket(S3_BUCKET_NAME).key(deleteKey.key()).build();
        s3.deleteObject(deleteObjectRequest);
    } catch (Exception e) {
        log.error("Error while deleting the object form S3" + e.toString());
    }
}
Also used : DeleteObjectRequest(software.amazon.awssdk.services.s3.model.DeleteObjectRequest) MalformedURLException(java.net.MalformedURLException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 24 with DeleteObjectRequest

use of com.amazonaws.s3.model.DeleteObjectRequest in project automatiko-engine by automatiko-io.

the class S3Store method remove.

public void remove(String processId, String processVersion, String processInstanceId, String... name) {
    String objectKey = createObjectKey(processId, processVersion, processInstanceId, name);
    DeleteObjectRequest deleteRequest = DeleteObjectRequest.builder().bucket(bucket).key(objectKey).build();
    s3.deleteObject(deleteRequest);
}
Also used : DeleteObjectRequest(software.amazon.awssdk.services.s3.model.DeleteObjectRequest)

Example 25 with DeleteObjectRequest

use of com.amazonaws.s3.model.DeleteObjectRequest in project stocator by SparkTC.

the class COSAPIClient method delete.

@Override
public boolean delete(String hostName, Path path, boolean recursive) throws IOException {
    String key = pathToKey(path);
    LOG.debug("Object name to delete {}. Path {}", key, path.toString());
    try {
        mClient.deleteObject(new DeleteObjectRequest(mBucket, key));
        memoryCache.removeFileStatus(path.toString());
        return true;
    } catch (AmazonServiceException e) {
        if (e.getStatusCode() != 404) {
            throw new IOException(e);
        }
    }
    LOG.warn("Delete on {} not found. Nothing to delete");
    return false;
}
Also used : DeleteObjectRequest(com.amazonaws.services.s3.model.DeleteObjectRequest) AmazonServiceException(com.amazonaws.AmazonServiceException) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException)

Aggregations

DeleteObjectRequest (com.amazonaws.services.s3.model.DeleteObjectRequest)25 DeleteObjectRequest (software.amazon.awssdk.services.s3.model.DeleteObjectRequest)19 IOException (java.io.IOException)11 AmazonClientException (com.amazonaws.AmazonClientException)7 AmazonServiceException (com.amazonaws.AmazonServiceException)7 S3Client (software.amazon.awssdk.services.s3.S3Client)6 S3Exception (software.amazon.awssdk.services.s3.model.S3Exception)6 HashMap (java.util.HashMap)4 SdkClientException (com.amazonaws.SdkClientException)3 SQSEvent (com.amazonaws.services.lambda.runtime.events.SQSEvent)3 SQSMessage (com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage)3 DeleteVersionRequest (com.amazonaws.services.s3.model.DeleteVersionRequest)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 Collections.singletonList (java.util.Collections.singletonList)3 Consumer (java.util.function.Consumer)3 Stream (java.util.stream.Stream)3 Assertions (org.assertj.core.api.Assertions)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 Assertions.assertThatExceptionOfType (org.assertj.core.api.Assertions.assertThatExceptionOfType)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3