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 | Retry Support | Transports Supported | Cloud Storage API used | Considerations |
---|---|---|---|---|---|---|
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) | Each chunk is retried up to the limitations specified in StorageOptions#getRetrySettings() | gRPC | Resumable Upload | The network will only be used for the following operations:
|
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. | Upload the file in the fewest number of RPC possible retrying within the limitations specified in StorageOptions#getRetrySettings() | gRPC | 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 | Resumable Upload |
|
Static Methods
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 |