private void copyFile ( String srcKey , String dstKey , long size ) throws IOException , InterruptedIOException , AmazonClientException { LOG . debug ( "copyFile {} -> {} " , srcKey , dstKey ) ; CopyObjectRequest copyObjectRequest = new CopyObjectRequest ( mBucket , srcKey , mBucket , dstKey ) ; try { ObjectMetadata srcmd = getObjectMetadata ( srcKey ) ; if ( srcmd != null ) { copyObjectRequest . setNewObjectMetadata ( srcmd ) ; } ProgressListener progressListener = new ProgressListener ( ) { public void progressChanged ( ProgressEvent progressEvent ) { switch ( progressEvent . getEventType ( ) ) { case TRANSFER_PART_COMPLETED_EVENT : break ; default : break ; } } } ; Copy copy = transfers . copy ( copyObjectRequest ) ; copy . addProgressListener ( progressListener ) ; try { copy . waitForCopyResult ( ) ; } catch ( InterruptedException e ) { throw new InterruptedIOException ( "Interrupted copying " + srcKey + " to " + dstKey + ", cancelling" ) ; } } catch ( AmazonClientException e ) { throw translateException ( "copyFile(" + srcKey + ", " + dstKey + ")" , srcKey , e ) ; } }
Copy a single object in the bucket via a COPY operation .