Search in sources :

Example 11 with DeleteObjectRequest

use of software.amazon.awssdk.services.s3.model.DeleteObjectRequest in project dataverse by IQSS.

the class S3AccessIO method delete.

@Override
public void delete() throws IOException {
    open();
    if (key == null) {
        throw new IOException("Failed to delete the object because the key was null");
    }
    try {
        DeleteObjectRequest deleteObjRequest = new DeleteObjectRequest(bucketName, key);
        s3.deleteObject(deleteObjRequest);
    } catch (AmazonClientException ase) {
        logger.warning("Caught an AmazonServiceException in S3AccessIO.delete():    " + ase.getMessage());
        throw new IOException("Failed to delete object" + dvObject.getId());
    }
}
Also used : DeleteObjectRequest(com.amazonaws.services.s3.model.DeleteObjectRequest) AmazonClientException(com.amazonaws.AmazonClientException) IOException(java.io.IOException)

Example 12 with DeleteObjectRequest

use of software.amazon.awssdk.services.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)10 AmazonServiceException (com.amazonaws.AmazonServiceException)5 IOException (java.io.IOException)4 AmazonS3 (com.amazonaws.services.s3.AmazonS3)3 DeleteVersionRequest (com.amazonaws.services.s3.model.DeleteVersionRequest)3 AmazonClientException (com.amazonaws.AmazonClientException)2 SdkClientException (com.amazonaws.SdkClientException)2 Regions (com.amazonaws.regions.Regions)2 InterruptedIOException (java.io.InterruptedIOException)2 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 DeleteObjectRequest (software.amazon.awssdk.services.s3.model.DeleteObjectRequest)2 S3Exception (software.amazon.awssdk.services.s3.model.S3Exception)2 ProfileCredentialsProvider (com.amazonaws.auth.profile.ProfileCredentialsProvider)1 AmazonS3Exception (com.amazonaws.services.s3.model.AmazonS3Exception)1 ChunkAlreadyExistsException (io.pravega.segmentstore.storage.chunklayer.ChunkAlreadyExistsException)1 ChunkNotFoundException (io.pravega.segmentstore.storage.chunklayer.ChunkNotFoundException)1 ChunkStorageException (io.pravega.segmentstore.storage.chunklayer.ChunkStorageException)1 ByteBuffer (java.nio.ByteBuffer)1 Random (java.util.Random)1