public final class BlobWriteSessionConfigs
Factory class to select and construct BlobWriteSessionConfigs.
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 StorageOptions#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 StorageOptions#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 StorageOptions#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 |
|
Static Methods
bidiWrite()
public static BidiBlobWriteSessionConfig bidiWrite()
Factory to produce a resumable upload using a bi-directional stream. This should provide a small performance increase compared to a regular resumable upload.
Configuration of the buffer size can be performed via BidiBlobWriteSessionConfig#withBufferSize(int).
Returns | |
---|---|
Type | Description |
BidiBlobWriteSessionConfig |
bufferToDiskThenUpload(Path path)
public static BufferToDiskThenUpload bufferToDiskThenUpload(Path path)
Create a new BlobWriteSessionConfig which will first buffer the content of the object
to a temporary file under the specified path
.
Once the file on disk is closed, the entire file will then be uploaded to Cloud Storage. See Also: Storage#blobWriteSession(BlobInfo, BlobWriteOption...), GrpcStorageOptions.Builder#setBlobWriteSessionConfig(BlobWriteSessionConfig)
Parameter | |
---|---|
Name | Description |
path |
Path |
Returns | |
---|---|
Type | Description |
BufferToDiskThenUpload |
Exceptions | |
---|---|
Type | Description |
IOException |
bufferToDiskThenUpload(Collection<Path> paths)
public static BufferToDiskThenUpload bufferToDiskThenUpload(Collection<Path> paths)
Create a new BlobWriteSessionConfig which will first buffer the content of the object
to a temporary file under one of the specified paths
.
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. See Also: Storage#blobWriteSession(BlobInfo, BlobWriteOption...), GrpcStorageOptions.Builder#setBlobWriteSessionConfig(BlobWriteSessionConfig)
Parameter | |
---|---|
Name | Description |
paths |
Collection<Path> |
Returns | |
---|---|
Type | Description |
BufferToDiskThenUpload |
Exceptions | |
---|---|
Type | Description |
IOException |
bufferToTempDirThenUpload()
public static BlobWriteSessionConfig bufferToTempDirThenUpload()
Create a new BlobWriteSessionConfig which will first buffer the content of the object
to a temporary file under java.io.tmpdir
.
Once the file on disk is closed, the entire file will then be uploaded to Cloud Storage. See Also: Storage#blobWriteSession(BlobInfo, BlobWriteOption...), GrpcStorageOptions.Builder#setBlobWriteSessionConfig(BlobWriteSessionConfig)
Returns | |
---|---|
Type | Description |
BlobWriteSessionConfig |
Exceptions | |
---|---|
Type | Description |
IOException |
getDefault()
public static DefaultBlobWriteSessionConfig 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). See Also: GrpcStorageDefaults#getDefaultStorageWriterConfig()
Returns | |
---|---|
Type | Description |
DefaultBlobWriteSessionConfig |
journaling(Collection<Path> paths)
public static JournalingBlobWriteSessionConfig journaling(Collection<Path> paths)
Create a new BlobWriteSessionConfig which will journal writes to a temporary file under
one of the specified paths
before transmitting the bytes to Cloud Storage.
The specifics of how the work is spread across multiple paths is undefined and subject to change. See Also: Storage#blobWriteSession(BlobInfo, BlobWriteOption...), GrpcStorageOptions.Builder#setBlobWriteSessionConfig(BlobWriteSessionConfig)
Parameter | |
---|---|
Name | Description |
paths |
Collection<Path> |
Returns | |
---|---|
Type | Description |
JournalingBlobWriteSessionConfig |
parallelCompositeUpload()
public static ParallelCompositeUploadBlobWriteSessionConfig parallelCompositeUpload()
Create a new BlobWriteSessionConfig which will perform a Parallel Composite Upload by breaking the stream into parts and composing the parts together to make the ultimate object. See Also: Storage#blobWriteSession(BlobInfo, BlobWriteOption...), GrpcStorageOptions.Builder#setBlobWriteSessionConfig(BlobWriteSessionConfig)
Returns | |
---|---|
Type | Description |
ParallelCompositeUploadBlobWriteSessionConfig |