Search code examples
symfonygoogle-cloud-storagegaufrette

Retrieving public path using KnpGaufretteBundle with GoogleCloudStorage adapter


After setting up the KnpGaufretteBundle with GoogleCloudStorage adapter, I am able to write files in the Google Cloud Storage.

But I have no clue on how to retrieve the public access link to that file (image, in this case).

Here is an example of the code I am using to write, if it is relevant in anyway. Actually I have to versions:

$fs = $this->get("knp_gaufrette.filesystem_map")->get("bucket_name");
$fs->write("image.jpg",file_get_contents("/path/to/file"));

or

$file = new \Gaufrette\File("image.jpg",$this->get("knp_gaufrette.filesystem_map")->get("bucket_name"));
$file->setContent(file_get_contents("/path/to/file"));

Any ideas on how to retrieve the public ("http://..") url from here?

Thanks!


Solution

  • Finally I could get around getting the url programatically.

    First I had to make the bucket public like this: https://cloud.google.com/storage/docs/access-control/making-data-public

    An then I got the url following this post:

    Get Public URL for File - Google Cloud Storage - App Engine (Python)