Class CopyWriter (2.9.2)

public class CopyWriter implements Restorable<CopyWriter>

Google Storage blob copy writer. A CopyWriter object allows to copy both blob's data and information. To override source blob's information supply a BlobInfo to the CopyRequest using either Storage.CopyRequest.Builder#setTarget(BlobInfo, Storage.BlobTargetOption...) or Storage.CopyRequest.Builder#setTarget(BlobInfo, Iterable).

This class holds the result of a copy request. If source and destination blobs share the same location and storage class the copy is completed in one RPC call otherwise one or more #copyChunk calls are necessary to complete the copy. In addition, CopyWriter#getResult() can be used to automatically complete the copy and return information on the newly created blob. See Also: Rewrite

Inheritance

java.lang.Object > CopyWriter

Implements

com.google.cloud.Restorable<com.google.cloud.storage.CopyWriter>

Methods

capture()

public RestorableState<CopyWriter> capture()
Returns
TypeDescription
com.google.cloud.RestorableState<CopyWriter>

copyChunk()

public void copyChunk()

Copies the next chunk of the blob. An RPC is issued only if copy has not finished yet (#isDone returns false).

getBlobSize()

public long getBlobSize()

Returns the size of the blob being copied.

Returns
TypeDescription
long

getResult()

public Blob getResult()

Returns the updated information for the written blob. Calling this method when isDone() is false will block until all pending chunks are copied.

This method has the same effect of doing:


 while (!copyWriter.isDone()) {
    copyWriter.copyChunk();
 }
 
Returns
TypeDescription
Blob

getTotalBytesCopied()

public long getTotalBytesCopied()

Returns the number of bytes copied.

Returns
TypeDescription
long

isDone()

public boolean isDone()

Returns true if blob copy has finished, false otherwise.

Returns
TypeDescription
boolean