Search in sources :

Example 11 with CopyWriter

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

the class BlobSnippets method copyToId.

/**
   * Example of copying the blob to a different bucket with a different name.
   */
// [TARGET copyTo(BlobId, BlobSourceOption...)]
// [VARIABLE "my_unique_bucket"]
// [VARIABLE "copy_blob_name"]
public Blob copyToId(String bucketName, String blobName) {
    // [START copyToId]
    CopyWriter copyWriter = blob.copyTo(BlobId.of(bucketName, blobName));
    Blob copiedBlob = copyWriter.getResult();
    // [END copyToId]
    return copiedBlob;
}
Also used : Blob(com.google.cloud.storage.Blob) CopyWriter(com.google.cloud.storage.CopyWriter)

Aggregations

CopyWriter (com.google.cloud.storage.CopyWriter)11 Blob (com.google.cloud.storage.Blob)10 BlobInfo (com.google.cloud.storage.BlobInfo)6 BlobId (com.google.cloud.storage.BlobId)5 Storage (com.google.cloud.storage.Storage)5 Test (org.junit.Test)5 CopyRequest (com.google.cloud.storage.Storage.CopyRequest)1 StorageException (com.google.cloud.storage.StorageException)1 CopyOption (java.nio.file.CopyOption)1 NoSuchFileException (java.nio.file.NoSuchFileException)1 StandardCopyOption (java.nio.file.StandardCopyOption)1