Class StorageBatch (2.1.10)

public class StorageBatch

A batch of operations to be submitted to Google Cloud Storage using a single RPC request.

Example of using a batch request to delete, update and get a blob:


 StorageBatch batch = storage.batch();
 BlobId firstBlob = BlobId.of("bucket", "blob1"));
 BlobId secondBlob = BlobId.of("bucket", "blob2"));
 batch.delete(firstBlob).notify(new BatchResult.Callback

Inheritance

java.lang.Object > StorageBatch

Methods

delete(BlobId blob, Storage.BlobSourceOption[] options)

public StorageBatchResult<Boolean> delete(BlobId blob, Storage.BlobSourceOption[] options)

Adds a request representing the "delete blob" operation to this batch. Calling StorageBatchResult#get() on the return value yields true upon successful deletion, false if the blob was not found, or throws a StorageException if the operation failed.

Parameters
Name Description
blob BlobId
options BlobSourceOption[]
Returns
Type Description
StorageBatchResult<Boolean>

delete(String bucket, String blob, Storage.BlobSourceOption[] options)

public StorageBatchResult<Boolean> delete(String bucket, String blob, Storage.BlobSourceOption[] options)

Adds a request representing the "delete blob" operation to this batch. Calling StorageBatchResult#get() on the return value yields true upon successful deletion, false if the blob was not found, or throws a StorageException if the operation failed.

Parameters
Name Description
bucket String
blob String
options BlobSourceOption[]
Returns
Type Description
StorageBatchResult<Boolean>

get(BlobId blob, Storage.BlobGetOption[] options)

public StorageBatchResult<Blob> get(BlobId blob, Storage.BlobGetOption[] options)

Adds a request representing the "get blob" operation to this batch. The options can be used in the same way as for Storage#get(BlobId, BlobGetOption...). Calling StorageBatchResult#get() on the return value yields the requested Blob if successful, null if no such blob exists, or throws a StorageException if the operation failed.

Parameters
Name Description
blob BlobId
options BlobGetOption[]
Returns
Type Description
StorageBatchResult<Blob>

get(String bucket, String blob, Storage.BlobGetOption[] options)

public StorageBatchResult<Blob> get(String bucket, String blob, Storage.BlobGetOption[] options)

Adds a request representing the "get blob" operation to this batch. The options can be used in the same way as for Storage#get(BlobId, BlobGetOption...). Calling StorageBatchResult#get() on the return value yields the requested Blob if successful, null if no such blob exists, or throws a StorageException if the operation failed.

Parameters
Name Description
bucket String
blob String
options BlobGetOption[]
Returns
Type Description
StorageBatchResult<Blob>

submit()

public void submit()

Submits this batch for processing using a single RPC request.

update(BlobInfo blobInfo, Storage.BlobTargetOption[] options)

public StorageBatchResult<Blob> update(BlobInfo blobInfo, Storage.BlobTargetOption[] options)

Adds a request representing the "update blob" operation to this batch. The options can be used in the same way as for Storage#update(BlobInfo, BlobTargetOption...). Calling StorageBatchResult#get() on the return value yields the updated Blob if successful, or throws a StorageException if the operation failed.

Parameters
Name Description
blobInfo BlobInfo
options BlobTargetOption[]
Returns
Type Description
StorageBatchResult<Blob>