I'm using the AmazonS3 Client in my Java Application to store objects in our Storage which is from Hitachi and has an S3 API. putObject()
does save the object correctly, but when i'm trying to modify the existinf object by using the identical body and object-ID, I get this exception:
com.amazonaws.services.s3.model.AmazonS3Exception: Object already exists. (Service: Amazon S3; Status Code: 409; Error Code: OperationAborted; Request ID: 1622623300123; S3 Extended Request ID: ZzEwLXByaS5hZC5kcmd1ZWxkZW5lci5kZToxMDI=), S3 Extended Request ID: ZzEwLXByaS5hZC5kcmd1ZWxkZW5lci5kZToxMDI="
This is how my request looks like:
private PutObjectRequest buildPutObjectRequest(String id, StorageObject storageObject, String currentBucket) throws JsonProcessingException {
ObjectWriter objectWriter = new ObjectMapper().writer().withDefaultPrettyPrinter();
String json = objectWriter.writeValueAsString(storageObject);
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(json.length());
return new PutObjectRequest(currentBucket, id, new ByteArrayInputStream(json.getBytes()), metadata);
}
Normally I'd expect to update the existing object using a PUT-Request. The documentation tells me that with versioning enabled a copy will be created but that's not what I want to do. Do you guys have a solution for this?
Enabling versioning is indeed the only way we have found to "overwrite" an object on HCP. In our tests enabling versioning did not appear to have any other unwanted side-effect. You can set a very short retention time to ensure few(er) versions are kept.