1
votes

I'm trying to write to a file in a Google Cloud Storage bucket from my App Engine using PHP. I've followed the documentation for setting up a bucket and accessing it via PHP:

I've added the app engine's Service Account Name as an owner of the bucket in question, but when I attempt to run something like the following:

$fp = fopen('gs://[bucket-name]/log/log.txt', 'a+');

I get the following error:

PHP Warning:  fopen(gs://[bucket-name]/log.txt): failed to open stream: 
"\google\appengine\ext\cloud_storage_streams\CloudStorageStreamWrapper::stream_open" 
call failed in /[myfile.php] on line 33

[bucket-name] is just a placeholder, I'm using the correct bucket name. Am I missing something?

1
FWIW, I also read the post @ stackoverflow.com/questions/20294785/… and tried to find alternate App Engine email identifiers to give ownership of the bucket to, but no luck.Charlie Schliesser

1 Answers

2
votes

a+ is not a valid mode for opening a GCS file. Objects in GCS can't be appended to. They can only be overwritten. You can find the valid modes here:

https://code.google.com/p/googleappengine/source/browse/trunk/python/php/sdk/google/appengine/ext/cloud_storage_streams/CloudStorageStreamWrapper.php?spec=svn404&r=400#56