5
votes

So ive followed the guide on how to use GCS on their site: https://developers.google.com/appengine/docs/php/googlestorage/

But the following code does not work. I cannot access my bucket, and the CloudStorageTools is not even found.

require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php';
use google\appengine\api\cloud_storage\CloudStorageTools;

// check if GCS bucket if writable
$my_bucket = 'gs://my_bucket/';
$check1 = is_writable($my_bucket); //returns nothing

class_exists("CloudStorageTools"); //returns false

I also added google_app_engine.allow_include_gs_buckets into the php.ini file. Still no support for GCS.

Anyone have some running code they could share?

2
I had issues getting GCS to work locally. It works on App Engine without adding the "require" script. But I'm stumped on how to make it work locally, suing the Google App Engine Launcher. Any ideas? - Mr Pablo
You solved this? - suarsenegger

2 Answers

3
votes

I think it may have something to do with permissions set to your bucket. Make sure you added your app account email Application Settings -> Service Account Name.

I ported my app with no issues and using Smarty to write into and include from the bucket. I did not have to declare:

require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php';
use google\appengine\api\cloud_storage\CloudStorageTools;

and the app reads and writes to the bucket with no problems.

I have had however issues with some WordPress porting, when although the bucket existed and had properly setup access permission, for some reason app throws a Fatal Error and I can see it in the app logs, that application was trying to access the cloud storage via gs:// wrapper.

Hope that helps.

-1
votes

Hi dude make sure you bucket is Public Write enabled

use this gsutil command to do so (google how to configure gsutil utility)

$ gsutil acl ch -u AllUsers:W gs://example-bucket-name