RBP
RBP

Reputation: 485

How to access file present inside bucket of another application

I am trying to read .txt file present inside bucket of another google application.

Below is my code

              GcsInputChannel readChannel = null;
              BufferedReader reader = null;
              GcsFilename filename = new GcsFilename("abc.appspot.com","For_Prod_Scripts.txt");

              GcsService gcsService = GcsServiceFactory.createGcsService();
              // We can now read the file through the API:
              readChannel = gcsService.openReadChannel(filename,0);
              // Again, different standard Java ways of reading from the channel.
              reader = new BufferedReader(Channels.newReader(readChannel, "UTF8"));
              //CsvReader csvReader = new CsvReader(reader);
              String line = reader.readLine();

              while ((line = reader.readLine()) != null) {
                  log.warning("READ:" + line);
                }

I have added below permissions into bucket permissions and object default permissions of that bucket.As shown in below image. 123412341234 is my another application's project id. Inside that i am accessing that bucket

enter image description here

I am getting below exception

java.lang.RuntimeException: com.google.appengine.tools.cloudstorage.SimpleGcsInputChannelImpl$1@1f75e55: Unexpected cause of ExecutionException

Am i missing something here?

Upvotes: 1

Views: 127

Answers (1)

RBP
RBP

Reputation: 485

Need to Add Service account email to bucket permissions for accessing files inside buckets.

Upvotes: 1

Related Questions