我正在使用com.google.cloud.storage
复制存储中的对象
这是我的代码:
import com.google.cloud.storage.*;
import com.google.cloud.storage.Storage.CopyRequest;
Storage storage = StorageOptions.getDefaultInstance().getService();
String copyBlobName = "copy_blob_name";
String bucketName = "my_unique_bucket";
String blobName = "my_blob_name";
CopyRequest request = CopyRequest.newBuilder()
.setSource(BlobId.of(bucketName, blobName))
.setTarget(BlobId.of(copyBlobName, copyBlobName))
.build();
storage.copy(request);
副本成功了 但我得到以下例外:
Exception in thread "main" java.lang.NoSuchMethodError: com.google.api.services.storage.model.RewriteResponse.getObjectSize()Ljava/math/BigInteger;
at com.google.cloud.storage.spi.DefaultStorageRpc.rewrite(DefaultStorageRpc.java:669)
at com.google.cloud.storage.spi.DefaultStorageRpc.openRewrite(DefaultStorageRpc.java:634)
at com.google.cloud.storage.StorageImpl$15.call(StorageImpl.java:438)
at com.google.cloud.storage.StorageImpl$15.call(StorageImpl.java:435)
at com.google.cloud.RetryHelper.doRetry(RetryHelper.java:179)
at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:244)
at com.google.cloud.storage.StorageImpl.copy(StorageImpl.java:435)
在pom.xml中:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
<version>0.8.3-beta</version>
</dependency>