Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use google cloud storage as Laravel 5 filesystem?

I'm developing an application that lets my users upload files, and I've made it works with "local" disk using filesystem feature, but now I want to migrate and use google Google Cloud Storage for it.

It has been a lot difficult to find some useful information. In the docs there is an "example" for work with dropbox, but it's not complete. It doesn't shows how to config drivers and disk, so it isn't clear enough for me.

I would like to know what to do, since I have no idea from now.

I've just used this tutorial http://www.codetutorial.io/laravel-5-file-upload-storage-download/ and it's working for local, so I really need to migrate to google cloud storage, and only that. I'm using openshift and I feel comfortable about it.

Could you please help me to know what should I configure filesystem to be used as I need?

Thank you

like image 678
Juan Sánchez Avatar asked Sep 26 '15 22:09

Juan Sánchez


1 Answers

I've found a solution.

It seems that Google Cloud Storage uses the same api than Amazon S3, so I could use it as I would use amazon, the same driver.

The only thing I needed to change was when I config disks in laravel, using this code in config/filesystems when adding a disk for google:

'google' => [
    'driver' => 's3',
     'key' => 'xxx',
     'secret' => 'xxx',
     'bucket' => 'qrnotesfiles',
     'base_url'=>'https://storage.googleapis.com'
]
like image 88
Juan Sánchez Avatar answered Sep 28 '22 19:09

Juan Sánchez