Reputation: 9389
So I have 2 app engine projects.
In one of my app engines, I have a google cloud storage component with it. Usually to connect to those cloud storage files I just do:
<?php
use google\appengine\api\cloud_storage\CloudStorageTools;
$document_data = "123";
$object_url = 'gs://{bucket}/FOLDER/file.ext';
$options = stream_context_create(['gs'=>['acl'=>'private']]);
$my_file = fopen($object_url, 'w', false, $options);
fwrite($my_file, $document_data);
fclose($my_file);
?>
or
<?php file_get_contents('gs://FOLDER/file.ext'); ?>
I have another app engine with no google cloud storage but i'd like to connect to the cloud storage in my other app engine.
Does anyone know how I could do that?
Upvotes: 1
Views: 130
Reputation: 2880
You need to give bucket permissions to the App Engine application as follows:
Click on 'Add new', select 'User' and select at least WRITER permissions. Type your App Engine service account in the text field. The App Engine service account has the format: <projectID>@appspot.gserviceaccount.com
Save the changes.
After these steps you should be able to connect to a bucket that belongs to another project.
Upvotes: 4