google-cloud-lib/src/main/java/com/streamsets/pipeline/stage/cloudstorage/origin/GcsObjectPostProcessingHandler.java
private void copy(BlobId sourceBlobId, String destinationBucket, String destinationPath, boolean deleteSource) {
    LOG.debug(
        "Copying object '{}' to Object '{}'",
        String.format(BLOB_PATH_TEMPLATE, sourceBlobId.getBucket(), sourceBlobId.getName()),
        String.format(BLOB_PATH_TEMPLATE, destinationBucket, destinationPath)
    );

    Storage.CopyRequest copyRequest = new Storage.CopyRequest.Builder()
        .setSource(sourceBlobId)
        .setTarget(BlobId.of(destinationBucket, destinationPath))
        .build();
    Blob destinationBlob = storage.copy(copyRequest).getResult();
    LOG.debug(
        "Copied object '{}' to Object '{}'",
        String.format(BLOB_PATH_TEMPLATE, sourceBlobId.getBucket(), sourceBlobId.getName()),
        String.format(BLOB_PATH_TEMPLATE, destinationBlob.getBlobId().getBucket(), destinationBlob.getBlobId().getName())
    );
    if (deleteSource) {
      delete(sourceBlobId);
    }
  }
private void copy(BlobId sourceBlobId, String destinationBucket, String destinationPath, boolean deleteSource) {
    LOG.debug(
        "Copying object '{}' to Object '{}'",
        String.format(BLOB_PATH_TEMPLATE, sourceBlobId.getBucket(), sourceBlobId.getName()),
        String.format(BLOB_PATH_TEMPLATE, destinationBucket, destinationPath)
    );

    Storage.CopyRequest copyRequest = new Storage.CopyRequest.Builder()
        .setSource(sourceBlobId)
        .setTarget(BlobId.of(destinationBucket, destinationPath))
        .build();
    Blob destinationBlob = storage.copy(copyRequest).getResult();
    LOG.debug(
        "Copied object '{}' to Object '{}'",
        String.format(BLOB_PATH_TEMPLATE, sourceBlobId.getBucket(), sourceBlobId.getName()),
        String.format(BLOB_PATH_TEMPLATE, destinationBlob.getBlobId().getBucket(), destinationBlob.getBlobId().getName())
    );
    if (deleteSource) {
      delete(sourceBlobId);
    }
  }
private void copy ( BlobId sourceBlobId , String destinationBucket , String destinationPath , boolean deleteSource ) { LOG . debug ( "Copying object '{}' to Object '{}'" , String . format ( BLOB_PATH_TEMPLATE , sourceBlobId . getBucket ( ) , sourceBlobId . getName ( ) ) , String . format ( BLOB_PATH_TEMPLATE , destinationBucket , destinationPath ) ) ; Storage . CopyRequest copyRequest = new Storage . CopyRequest . Builder ( ) . setSource ( sourceBlobId ) . setTarget ( BlobId . of ( destinationBucket , destinationPath ) ) . build ( ) ; Blob destinationBlob = storage . copy ( copyRequest ) . getResult ( ) ; LOG . debug ( "Copied object '{}' to Object '{}'" , String . format ( BLOB_PATH_TEMPLATE , sourceBlobId . getBucket ( ) , sourceBlobId . getName ( ) ) , String . format ( BLOB_PATH_TEMPLATE , destinationBlob . getBlobId ( ) . getBucket ( ) , destinationBlob . getBlobId ( ) . getName ( ) ) ) ; if ( deleteSource ) { delete ( sourceBlobId ) ; } }
Copy a blob for gcs to a destination bucket and a path (and delete the source blob if needed)
@param sourceBlobId sourceBlobId
@param destinationBucket destination bucket
@param destinationPath destination path
@param deleteSource delete source blob
Copy a blob for gcs to a destination bucket and a path ( and delete the source blob if needed )