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());
}
}
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;
}
Aggregations