Package com.google.cloud.storage
Class CopyWriter
java.lang.Object
com.google.cloud.storage.CopyWriter
- All Implemented Interfaces:
com.google.cloud.Restorable<CopyWriter>
- Direct Known Subclasses:
HttpCopyWriter
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, getResult()
can be used to automatically complete the copy and return information on the newly created blob.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionabstract com.google.cloud.RestorableState<CopyWriter>
capture()
abstract void
Copies the next chunk of the blob.abstract long
Returns the size of the blob being copied.abstract Blob
Returns the updated information for the written blob.abstract long
Returns the number of bytes copied.abstract boolean
isDone()
Returnstrue
if blob copy has finished,false
otherwise.
-
Method Details
-
getResult
Returns the updated information for the written blob. Calling this method whenisDone()
isfalse
will block until all pending chunks are copied.This method has the same effect of doing:
while (!copyWriter.isDone()) { copyWriter.copyChunk(); }
- Throws:
StorageException
- upon failure
-
getBlobSize
public abstract long getBlobSize()Returns the size of the blob being copied. -
isDone
public abstract boolean isDone()Returnstrue
if blob copy has finished,false
otherwise. -
getTotalBytesCopied
public abstract long getTotalBytesCopied()Returns the number of bytes copied. -
copyChunk
public abstract void copyChunk()Copies the next chunk of the blob. An RPC is issued only if copy has not finished yet (isDone()
returnsfalse
).- Throws:
StorageException
- upon failure
-
capture
- Specified by:
capture
in interfacecom.google.cloud.Restorable<CopyWriter>
-