2

根据文档,可以使用 HTTP 批量插入到 Google Cloud Storage 服务。但是如何使用 Java API 做到这一点?我似乎找不到任何文档或示例。

4

1 回答 1

2

根据文档,谷歌提供了一个谷歌云客户端库。该库的java doc提供了以下示例代码来使用单个请求发出批处理请求RPC

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
于 2016-06-07T10:23:48.227 回答