public class StorageBatch extends Object
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<Boolean, StorageException>() {
public void success(Boolean result) {
// deleted successfully
}
public void error(StorageException exception) {
// delete failed
}
});
batch.update(BlobInfo.builder(secondBlob).contentType("text/plain").build());
StorageBatchResult<Blob> result = batch.get(secondBlob);
batch.submit();
Blob blob = result.get(); // returns get result or throws StorageException
Modifier and Type | Method and Description |
---|---|
StorageBatchResult<Boolean> |
delete(BlobId blob,
Storage.BlobSourceOption... options)
Adds a request representing the "delete blob" operation to this batch.
|
StorageBatchResult<Boolean> |
delete(String bucket,
String blob,
Storage.BlobSourceOption... options)
Adds a request representing the "delete blob" operation to this batch.
|
StorageBatchResult<Blob> |
get(BlobId blob,
Storage.BlobGetOption... options)
Adds a request representing the "get blob" operation to this batch.
|
StorageBatchResult<Blob> |
get(String bucket,
String blob,
Storage.BlobGetOption... options)
Adds a request representing the "get blob" operation to this batch.
|
void |
submit()
Submits this batch for processing using a single RPC request.
|
StorageBatchResult<Blob> |
update(BlobInfo blobInfo,
Storage.BlobTargetOption... options)
Adds a request representing the "update blob" operation to this batch.
|
public StorageBatchResult<Boolean> delete(String bucket, String blob, Storage.BlobSourceOption... options)
BatchResult.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.public StorageBatchResult<Boolean> delete(BlobId blob, Storage.BlobSourceOption... options)
BatchResult.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.public StorageBatchResult<Blob> update(BlobInfo blobInfo, Storage.BlobTargetOption... options)
options
can
be used in the same way as for Storage.update(BlobInfo, BlobTargetOption...)
. Calling
BatchResult.get()
on the return value yields the updated Blob
if
successful, or throws a StorageException
if the operation failed.public StorageBatchResult<Blob> get(String bucket, String blob, Storage.BlobGetOption... options)
options
can be
used in the same way as for Storage.get(BlobId, BlobGetOption...)
. Calling BatchResult.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.public StorageBatchResult<Blob> get(BlobId blob, Storage.BlobGetOption... options)
options
can be
used in the same way as for Storage.get(BlobId, BlobGetOption...)
. Calling BatchResult.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.public void submit()
Copyright © 2023 Google LLC. All rights reserved.