Class BlobWriteSessionConfigs
BlobWriteSessionConfig
s.
There are several strategies which can be used to upload a Blob
to Google Cloud
Storage. This class provides factories which allow you to select the appropriate strategy for
your workload.
Strategy | Factory Method(s) | Description | Transport(s) Supported | Considerations | Retry Support | Cloud Storage API used |
---|---|---|---|---|---|---|
Default (Chunk based upload) | getDefault() |
Buffer up to a configurable amount of bytes in memory, write to Cloud Storage when
full or close. Buffer size is configurable via
DefaultBlobWriteSessionConfig.withChunkSize(int)
|
gRPC | The network will only be used for the following operations:
|
Each chunk is retried up to the limitations specified in
ServiceOptions.getRetrySettings()
|
Resumable Upload |
Buffer to disk then upload |
Buffer bytes to a temporary file on disk. On close()
upload the entire files contents to Cloud Storage. Delete the temporary file.
|
gRPC |
|
Upload the file in the fewest number of RPC possible retrying within the limitations
specified in ServiceOptions.getRetrySettings()
|
Resumable Upload | |
Journal to disk while uploading | journaling(Collection<Path>) |
Create a Resumable Upload Session, before transmitting bytes to Cloud Storage write to a recovery file on disk. If the stream to Cloud Storage is interrupted with a retryable error query the offset of the Resumable Upload Session, then open the recovery file from the offset and transmit the bytes to Cloud Storage. | gRPC |
|
Opening the stream for upload will be retried up to the limitations specified in ServiceOptions.getRetrySettings()
All bytes are buffered to disk and allow for recovery from any arbitrary offset.
|
Resumable Upload |
Parallel Composite Upload | parallelCompositeUpload() |
Break the stream of bytes into smaller part objects uploading each part in parallel. Then composing the parts together to make the ultimate object. | gRPC |
|
Automatic retires will be applied for the following:
Storage.blobWriteSession(BlobInfo, BlobWriteOption...) .
Either Storage.BlobTargetOption.doesNotExist() or Storage.BlobTargetOption.generationMatch(long)
should be specified in order to make the final request idempotent.
Each operation will be retried up to the limitations specified in |
- Since:
- 2.26.0 This new api is in preview and is subject to breaking changes.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic BufferToDiskThenUpload
bufferToDiskThenUpload
(Path path) Create a newBlobWriteSessionConfig
which will first buffer the content of the object to a temporary file under the specifiedpath
.static BufferToDiskThenUpload
bufferToDiskThenUpload
(Collection<Path> paths) Create a newBlobWriteSessionConfig
which will first buffer the content of the object to a temporary file under one of the specifiedpaths
.static BlobWriteSessionConfig
Create a newBlobWriteSessionConfig
which will first buffer the content of the object to a temporary file underjava.io.tmpdir
.Factory to produce the default configuration for uploading an object to Cloud Storage.journaling
(Collection<Path> paths) Create a newBlobWriteSessionConfig
which will journal writes to a temporary file under one of the specifiedpaths
before transmitting the bytes to Cloud Storage.Create a newBlobWriteSessionConfig
which will perform a Parallel Composite Upload by breaking the stream into parts and composing the parts together to make the ultimate object.
-
Method Details
-
getDefault
Factory to produce the default configuration for uploading an object to Cloud Storage.Configuration of the chunk size can be performed via
DefaultBlobWriteSessionConfig.withChunkSize(int)
.- Since:
- 2.26.0 This new api is in preview and is subject to breaking changes.
- See Also:
-
bufferToTempDirThenUpload
@BetaApi @TransportCompatibility(GRPC) public static BlobWriteSessionConfig bufferToTempDirThenUpload() throws IOExceptionCreate a newBlobWriteSessionConfig
which will first buffer the content of the object to a temporary file underjava.io.tmpdir
.Once the file on disk is closed, the entire file will then be uploaded to Cloud Storage.
- Throws:
IOException
- Since:
- 2.26.0 This new api is in preview and is subject to breaking changes.
- See Also:
-
bufferToDiskThenUpload
@BetaApi @TransportCompatibility(GRPC) public static BufferToDiskThenUpload bufferToDiskThenUpload(Path path) throws IOException Create a newBlobWriteSessionConfig
which will first buffer the content of the object to a temporary file under the specifiedpath
.Once the file on disk is closed, the entire file will then be uploaded to Cloud Storage.
- Throws:
IOException
- Since:
- 2.26.0 This new api is in preview and is subject to breaking changes.
- See Also:
-
bufferToDiskThenUpload
@BetaApi @TransportCompatibility(GRPC) public static BufferToDiskThenUpload bufferToDiskThenUpload(Collection<Path> paths) throws IOException Create a newBlobWriteSessionConfig
which will first buffer the content of the object to a temporary file under one of the specifiedpaths
.Once the file on disk is closed, the entire file will then be uploaded to Cloud Storage.
The specifics of how the work is spread across multiple paths is undefined and subject to change.
- Throws:
IOException
- Since:
- 2.26.0 This new api is in preview and is subject to breaking changes.
- See Also:
-
journaling
@BetaApi @TransportCompatibility(GRPC) public static JournalingBlobWriteSessionConfig journaling(Collection<Path> paths) Create a newBlobWriteSessionConfig
which will journal writes to a temporary file under one of the specifiedpaths
before transmitting the bytes to Cloud Storage.The specifics of how the work is spread across multiple paths is undefined and subject to change.
- Since:
- 2.27.0 This new api is in preview and is subject to breaking changes.
- See Also:
-
parallelCompositeUpload
@BetaApi @TransportCompatibility(GRPC) public static ParallelCompositeUploadBlobWriteSessionConfig parallelCompositeUpload()Create a newBlobWriteSessionConfig
which will perform a Parallel Composite Upload by breaking the stream into parts and composing the parts together to make the ultimate object.- Since:
- 2.28.0 This new api is in preview and is subject to breaking changes.
- See Also:
-