@@ -324,31 +324,25 @@ public void writeBlobAtomic(OperationPurpose purpose, String blobName, BytesRefe
324
324
* Server-side copy can be done for any size object, but if the object is larger than 5 GB then
325
325
* it must be done through a series of part copy operations rather than a single blob copy.
326
326
* See <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_CopyObject.html">CopyObject</a>.
327
+ * Note that this operation will overwrite the destination if it already exists.
327
328
* @param purpose The purpose of the operation
328
329
* @param sourceBlobName The name of the blob to copy from
329
330
* @param destinationBlobContainer The blob container to copy the blob into
330
331
* @param destinationBlobName The name of the blob to copy to
331
- * @param failIfAlreadyExists Whether to throw a FileAlreadyExistsException if the target blob already exists
332
- * On S3, if true, throws UnsupportedOperationException because we don't know how
333
- * to do this atomically.
334
- * @throws IOException
332
+ * @throws IOException If the operation fails on the server side
335
333
*/
336
334
@ Override
337
335
public void copyBlob (
338
336
OperationPurpose purpose ,
339
337
String sourceBlobName ,
340
338
BlobContainer destinationBlobContainer ,
341
- String destinationBlobName ,
342
- boolean failIfAlreadyExists
339
+ String destinationBlobName
343
340
) throws IOException {
344
341
assert BlobContainer .assertPurposeConsistency (purpose , sourceBlobName );
345
342
assert BlobContainer .assertPurposeConsistency (purpose , destinationBlobName );
346
343
if (destinationBlobContainer instanceof S3BlobContainer == false ) {
347
344
throw new IllegalArgumentException ("target blob container must be a S3BlobContainer" );
348
345
}
349
- if (failIfAlreadyExists ) {
350
- throw new UnsupportedOperationException ("S3 blob container does not support failIfAlreadyExists" );
351
- }
352
346
353
347
final var s3TargetBlobContainer = (S3BlobContainer ) destinationBlobContainer ;
354
348
@@ -365,7 +359,10 @@ public void copyBlob(
365
359
try (AmazonS3Reference clientReference = blobStore .clientReference ()) {
366
360
SocketAccess .doPrivilegedVoid (() -> { clientReference .client ().copyObject (copyRequest ); });
367
361
} catch (final AmazonClientException e ) {
368
- throw new IOException ("Unable to copy object [" + sourceBlobName + "]" , e );
362
+ throw new IOException (
363
+ "Unable to copy object [" + sourceBlobName + "] to [" + destinationBlobContainer + "][" + destinationBlobName + "]" ,
364
+ e
365
+ );
369
366
}
370
367
}
371
368
0 commit comments