我正在关注以下链接。
我创建了一个新的 Google Cloud 项目并按照上述说明操作,在远程服务器上一切正常
我尝试使用现有的旧应用引擎项目(创建于 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 库并且没有另外指定,您将充当项目的 App Engine 默认服务帐户。它的名称可能类似于 your-project-id@appspot.gserviceaccount.com。
要获取服务帐户名称,open the Service Accounts page在控制台中,或检查 App Engine 上的设置页面。
关于google-app-engine - 无法在 Google Cloud Storage 上创建文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45347771/