Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not able to create the file on Google Cloud Storage

I am following the below link.

https://github.com/GoogleCloudPlatform/getting-started-java/tree/master/bookshelf-standard/3-binary-data

I create a new Google Cloud Project and followed the above instructions and all fine on the remote server

I tried using an existing old appengine project (created 4-5 years ago). I get the following error at the given code:

"Caller does not have storage.objects.create access to bucket ..."

 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());

Following is the stacktrace

  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

I checked up the Google Service Accounts in my old project and it exists. How do I know, who is the 'Caller'?

like image 786
Rajesh Avatar asked Jul 27 '17 10:07

Rajesh


People also ask

How do I add files to Google Cloud?

Drag and drop the desired files from your desktop or file manager to the main pane in the Google Cloud console. Click the Upload Files button, select the files you want to upload in the dialog that appears, and click Open.

How long is Google cloud free trial?

The free cloud platform tier allows you to access the incredible features of Google's cloud in two different ways: 12-month free trial. Always Free.


1 Answers

If you use the google-cloud libraries from App Engine and don't otherwise specify, you will be acting as your project's app engine default service account. Its name is probably something like [email protected].

To get the service account name, open the Service Accounts page in the console, or check the settings on your App Engine page.

like image 197
Brandon Yarbrough Avatar answered Sep 21 '22 15:09

Brandon Yarbrough