Retrieving public path using KnpGaufretteBundle with GoogleCloudStorage adapter

721 views Asked by At

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!

2

There are 2 answers

0
Vlad Dogarescu On BEST ANSWER

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)

0
Vincent On

Have a look at Gaufrette Extra (gaufrette extra). You should be able to implement it easily by copying the way they are doing it for Amazon S3