How can i access Buckets from a Google AppEngine App

780 views
Skip to first unread message

MarcoCanali

unread,
Nov 20, 2013, 12:02:05 PM11/20/13
to google-a...@googlegroups.com
Ok, i've a simple php page on google appengine with the code in the google PHP doc : 

function accessGS(){

    $options = [ "gs" => [ "Content-Type" => "text/plain" ]];
    $ctx = stream_context_create($options);
    file_put_contents("gs://mybucket/myFile.txt", "Hello", 0, $ctx);
    return file_get_contents("gs://mybucket/myFile.txt");
  }

and i received the error : 

Warning: Access Denied in /base/data/home/runtimes/php/sdk/google/appengine/ext/cloud_storage_streams/CloudStorageWriteClient.php on line 116
Warning: file_put_contents(gs://meteo/HelloWorld.txt): failed to open stream: "\google\appengine\ext\cloud_storage_streams\CloudStorageStreamWrapper::stream_open" call failed in .... 
Warning: Cloud Storage Error: FORBIDDEN in /base/data/home/runtimes/php/sdk/google/appengine/ext/cloud_storage_streams/CloudStorageReadClient.php on line 285 Warning: file_get_contents(gs://meteo/HelloWorld.txt): failed to open stream: "\google\appengine\ext\cloud_storage_streams\CloudStorageStreamWrapper::stream_open" call failed in /base ... 

What does i need for authenticate my simple PHP page on GAE for access data on GS ?? 


Vinny P

unread,
Nov 21, 2013, 6:15:53 PM11/21/13
to google-a...@googlegroups.com
On Wed, Nov 20, 2013 at 11:02 AM, MarcoCanali <marco....@gmail.com> wrote:
What does i need for authenticate my simple PHP page on GAE for access data on GS ?? 



You need to tell the GCS bucket that your application is allowed access to it. I wrote up a short demonstration at http://learntogoogleit.com/post/54528163872/setting-permissions-to-access-cloud-storage-from-app a few months ago but the basic idea is to go to the bucket's Bucket Permissions page, then grant access by typing in (your application id) @ appspot . gserviceaccount . com into the textbox prompt.

 
-----------------
-Vinny P
Technology & Media Advisor
Chicago, IL

App Engine Code Samples: http://www.learntogoogleit.com

Reply all
Reply to author
Forward
0 new messages