Search in sources :

Example 1 with ComposeRequest

use of com.google.cloud.storage.Storage.ComposeRequest in project google-cloud-java by GoogleCloudPlatform.

the class StorageSnippets method composeBlobs.

/**
   * Example of composing two blobs.
   */
// [TARGET compose(ComposeRequest)]
// [VARIABLE "my_unique_bucket"]
// [VARIABLE "my_blob_name"]
// [VARIABLE "source_blob_1"]
// [VARIABLE "source_blob_2"]
public Blob composeBlobs(String bucketName, String blobName, String sourceBlob1, String sourceBlob2) {
    // [START composeBlobs]
    BlobId blobId = BlobId.of(bucketName, blobName);
    BlobInfo blobInfo = BlobInfo.newBuilder(blobId).setContentType("text/plain").build();
    ComposeRequest request = ComposeRequest.newBuilder().setTarget(blobInfo).addSource(sourceBlob1).addSource(sourceBlob2).build();
    Blob blob = storage.compose(request);
    // [END composeBlobs]
    return blob;
}
Also used : Blob(com.google.cloud.storage.Blob) BlobInfo(com.google.cloud.storage.BlobInfo) ComposeRequest(com.google.cloud.storage.Storage.ComposeRequest) BlobId(com.google.cloud.storage.BlobId)

Aggregations

Blob (com.google.cloud.storage.Blob)1 BlobId (com.google.cloud.storage.BlobId)1 BlobInfo (com.google.cloud.storage.BlobInfo)1 ComposeRequest (com.google.cloud.storage.Storage.ComposeRequest)1