RemiSirdata / l5-google-cloud-storage by RemiSirdata
forked from websightgmbh/l5-google-cloud-storage

Laravel 5 Flysystem Google Cloud Storage Service Provider
198
0
2
Package Data
Maintainer Username: RemiSirdata
Maintainer Contact: rde@sirdata.fr (Rémi Demol)
Package Create Date: 2016-06-07
Package Last Update: 2016-06-07
Language: PHP
License: MIT
Last Refreshed: 2024-04-17 15:10:49
Package Statistics
Total Downloads: 198
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 2
Total Forks: 1
Total Open Issues: 0

Google Cloud Storage ServiceProvider for Laravel 5 Apps

Latest Stable Version Total Downloads Latest Unstable Version License

Wraps superbalist/flysystem-google-storage in a Laravel 5 / 5.1 compatible Service Provider.

Configuration

  1. Obtain the p12 certificate of a dedicated CloudPlatform Service Account

  2. Add the service provider to your application in config/app.php

    Websight\GcsProvider\CloudStorageServiceProvider::class,
    
  3. Add a disk to config/filesystems.php

    'gcs' => [
        // Select the Google Cloud Storage Disk
        'driver'                               => 'gcs',
        // The id of your new service account
        'service_account'                      => 'service@account.iam.gserviceaccount.com',
        // The location of the json service account file
        'service_account_json'          => storage_path() . '/service_account.json',
        // The bucket you want this disk to point at (To change with your bucket name)
        'bucket'                               => 'cloud-storage-bucket',
    ],
    

Usage

Use it like any other Flysystem Adapter with the Storage-Facade.

// Put a private file on the 'gcs' disk which is a Google Cloud Storage bucket
Storage::disk('gcs')->put('test.png', file_get_contents(storage_path('/app/test.png')));

// Put a public-accessible file on the 'gcs' disk which is a Google Cloud Storage bucket
Storage::disk('gcs')->put(
    'test-public.png',
    file_get_contents(storage_path('/app/test-public.png')),
    \Illuminate\Contracts\Filesystem\Filesystem::VISIBILITY_PUBLIC
);

// Retrieve a file
$file = Storage::disk('gcs')->get('test.png');

License (MIT)

Copyright (c) 2016 websight GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.