无法在Google云端存储上创建该文件
问题描述:
我正在关注以下链接。无法在Google云端存储上创建该文件
我创建了一个新的谷歌云项目,并遵循上述说明和所有罚款远程服务器
我使用现有旧的AppEngine项目(创建4-5年前)试穿。我会在给定的代码以下错误:
“来电不必斗storage.objects.create访问......”
storage.create(BlobInfo.newBuilder(bucketName, fileName)
// Modify access list to allow all users with link to read file
.setAcl(new ArrayList<>(Arrays.asList(Acl.of(User.ofAllUsers(),
Role.READER)))).build(),
fileStream.openStream());
以下是堆栈跟踪
Uncaught exception from servlet
com.google.cloud.storage.StorageException: Caller does not have storage.objects.create access to bucket asw12.
at com.google.cloud.storage.spi.v1.HttpStorageRpc.translate(HttpStorageRpc.java:189)
at com.google.cloud.storage.spi.v1.HttpStorageRpc.create(HttpStorageRpc.java:240)
at com.google.cloud.storage.StorageImpl$3.call(StorageImpl.java:151)
at com.google.cloud.storage.StorageImpl$3.call(StorageImpl.java:148)
at com.google.api.gax.retrying.DirectRetryingExecutor.submit(DirectRetryingExecutor.java:94)
at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:54)
at com.google.cloud.storage.StorageImpl.create(StorageImpl.java:148)
at com.google.cloud.storage.StorageImpl.create(StorageImpl.java:141)
at com.example.getstarted.util.CloudStorageHelper.uploadFile(CloudStorageHelper.java:65)
at com.example.getstarted.basicactions.CreateBookServlet.doPost(CreateBookServlet.java:70
我在我的旧项目中检查了Google服务帐户并存在。我怎么知道,谁是'来电者'?
答
如果您使用来自App Engine的google-cloud库,并且未另行指定,那么您将充当您项目的应用引擎默认服务帐户。它的名字可能类似于[email protected]。
要在控制台中获取服务帐户名称open the Service Accounts page,或者检查App Engine页面上的设置。
我打开了'服务帐户页面'。 Appengine默认服务帐户就像您提到的那样存在。另外,请说明一下,我应该如何检查Appengine页面中的设置? – Rajesh
我添加了[email protected]作为存储桶的存储对象创建器。现在好了。谢谢。 – Rajesh