0
votes

I have a bucket on Google Storage with public files, and I have a PHP web application running on another hosting (not App Engine). I wasn't able to figure out how to access those files from my application - the Documentation only covers access by app engine's apps. Does someone has managed to access a Storage bucket from a PHP app outside Google Cloud Platform?

1
Search Google "Google Storage PHP". One of the top results leads you here: cloud.google.com/php/samples/storagerandom_user_name
My problem is expressed on that same page: "This document describes how to use the Google Cloud Client Library to store and retrieve data using Cloud Storage in an App Engine app."Jorge Monteiro Jr

1 Answers

1
votes

The programmatic access is done just about the same when using Google Cloud PHP, but you'll need to do a bit more work to authenticate when running on a non-app engine/compute engine server. The best way is to use a Service Account. Google Cloud PHP has some documentation on how to get started with a Service Account.

Once you have your service account keyfile (it's a .json file), just create your client, providing it with the keyfile location.

use Google\Cloud\Storage\StorageClient;

$storage = new StorageClient([
    'keyFilePath' => '/path/to/keyfile.json'
]);

Once you've done this, you will be authenticated and able to make calls just as you could on app engine.