How to use google cloud storage as Laravel 5 filesystem?

11,326

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'
]
Share:
11,326
Juan Sánchez
Author by

Juan Sánchez

I'm looking for ways to improve each day, I try to learn from what I do in my daily tasks and help others when I can.

Updated on June 16, 2022

Comments

  • Juan Sánchez
    Juan Sánchez almost 2 years

    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

  • zundi
    zundi about 7 years
    Where do I find my key/secret? Can't seem to see it in GCP
  • Varun Varunesh
    Varun Varunesh about 6 years
    This link says how to create the key/secret cloud.google.com/storage/docs/migrating#keys
  • karni
    karni almost 6 years
    It seems like Aws\S3\S3Client no longer supports passing base_url? league/flysystem-aws-s3-v3 ^1.0
  • carestad
    carestad about 5 years
    Does this still work? Getting an error about missing region
  • exabyssus
    exabyssus almost 5 years
    To get "league/flysystem-aws-s3-v3": "^1.0" working specify region and set endpoint instead of base_url.