All Projects → Superbalist → Laravel Google Cloud Storage

Superbalist / Laravel Google Cloud Storage

Licence: mit
A Google Cloud Storage filesystem for Laravel

Projects that are alternatives of or similar to Laravel Google Cloud Storage

Flysystem Google Cloud Storage
Flysystem Adapter for Google Cloud Storage
Stars: ✭ 237 (-42.89%)
Mutual labels:  google-cloud, google-cloud-platform, google-cloud-storage
Google Cloud Cpp
C++ Client Libraries for Google Cloud Services
Stars: ✭ 233 (-43.86%)
Mutual labels:  google-cloud, google-cloud-platform, google-cloud-storage
restme
Template to bootstrap a fully functional, multi-region, REST service on GCP with a developer release pipeline.
Stars: ✭ 19 (-95.42%)
Mutual labels:  google-cloud, google-cloud-platform
arc gcs
Provides an Arc backend for Google Cloud Storage
Stars: ✭ 48 (-88.43%)
Mutual labels:  google-cloud-storage, google-cloud
rowy
Open-source Airtable-like experience for your database (Firestore) with GCP's scalability. Build any automation or cloud functions for your product. ⚡️✨
Stars: ✭ 2,676 (+544.82%)
Mutual labels:  google-cloud, google-cloud-platform
bazel-cache
Minimal cloud oriented Bazel gRPC cache
Stars: ✭ 33 (-92.05%)
Mutual labels:  google-cloud-storage, google-cloud
gcp-dataprep-bigquery-twitter-stream
Stream Twitter Data into BigQuery with Cloud Dataprep
Stars: ✭ 21 (-94.94%)
Mutual labels:  google-cloud-storage, google-cloud-platform
pipeline-editor
Cloud Pipelines Editor is a web app that allows the users to build and run Machine Learning pipelines without having to set up development environment.
Stars: ✭ 22 (-94.7%)
Mutual labels:  google-cloud, google-cloud-platform
go-bqloader
bqloader is a simple ETL framework to load data from Cloud Storage into BigQuery.
Stars: ✭ 16 (-96.14%)
Mutual labels:  google-cloud-storage, google-cloud
Laravel Recaptcha
Google ReCaptcha package for Laravel
Stars: ✭ 273 (-34.22%)
Mutual labels:  laravel, laravel5
Cors
🔮Supported(Laravel/Lumen/PSR-15/Swoft/Slim/ThinkPHP) - PHP CORS (Cross-origin resource sharing) middleware.
Stars: ✭ 266 (-35.9%)
Mutual labels:  laravel, laravel5
Laravel5 Jsonapi
Laravel 5 JSON API Transformer Package
Stars: ✭ 313 (-24.58%)
Mutual labels:  laravel, laravel5
appengine-java-standard
Google App Engine Standard Java runtime: Prod runtime, local devappserver, Cloud SDK Java components, GAE APIs, and GAE API emulators.
Stars: ✭ 141 (-66.02%)
Mutual labels:  google-cloud, google-cloud-platform
Google-Cloud-Study-Jams
Resources for 30 Days of Google Cloud program workshops and events conducted by GDSC VJTI
Stars: ✭ 13 (-96.87%)
Mutual labels:  google-cloud, google-cloud-platform
server
The ViUR application development framework - legacy version 2.x for Python 2.7
Stars: ✭ 12 (-97.11%)
Mutual labels:  google-cloud-storage, google-cloud
notionproxy
Notion as a web site, inspired by react-notion-x.
Stars: ✭ 24 (-94.22%)
Mutual labels:  google-cloud, google-cloud-platform
ob google-bigquery
This service is meant to simplify running Google Cloud operations, especially BigQuery tasks. This means you do not have to worry about installation, configuration or ongoing maintenance related to an SDK environment. This can be helpful to those who would prefer to not to be responsible for those activities.
Stars: ✭ 43 (-89.64%)
Mutual labels:  google-cloud, google-cloud-platform
Coastercms
The repository for Coaster CMS (coastercms.org), a full featured, Laravel based Content Management System
Stars: ✭ 380 (-8.43%)
Mutual labels:  laravel, laravel5
monolog-google-cloud-json-formatter
A Monolog extension for formatting log entries for Google Cloud Logging
Stars: ✭ 15 (-96.39%)
Mutual labels:  google-cloud, google-cloud-platform
argon
Campaign Manager 360 and Display & Video 360 Reports to BigQuery connector
Stars: ✭ 31 (-92.53%)
Mutual labels:  google-cloud, google-cloud-platform

laravel-google-cloud-storage

A Google Cloud Storage filesystem for Laravel.

Author Build Status Software License Packagist Version Total Downloads

This package is a wrapper bridging flysystem-google-storage into Laravel as an available storage disk.

Installation

composer require superbalist/laravel-google-cloud-storage

If you are on Laravel 5.4 or earlier, then register the service provider in app.php

'providers' => [
    // ...
    Superbalist\LaravelGoogleCloudStorage\GoogleCloudStorageServiceProvider::class,
]

If you are on Laravel 5.5 or higher, composer will have registered the provider automatically for you.

Add a new disk to your filesystems.php config

'gcs' => [
    'driver' => 'gcs',
    'project_id' => env('GOOGLE_CLOUD_PROJECT_ID', 'your-project-id'),
    'key_file' => env('GOOGLE_CLOUD_KEY_FILE', null), // optional: /path/to/service-account.json
    'bucket' => env('GOOGLE_CLOUD_STORAGE_BUCKET', 'your-bucket'),
    'path_prefix' => env('GOOGLE_CLOUD_STORAGE_PATH_PREFIX', null), // optional: /default/path/to/apply/in/bucket
    'storage_api_uri' => env('GOOGLE_CLOUD_STORAGE_API_URI', null), // see: Public URLs below
    'visibility' => 'public', // optional: public|private
],

Authentication

The Google Client uses a few methods to determine how it should authenticate with the Google API.

  1. If you specify a path in the key key_file in disk config, that json credentials file will be used.

  2. If the GOOGLE_APPLICATION_CREDENTIALS env var is set, it will use that.

    putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json');
    
  3. It will then try load the key file from a 'well known path':

    • windows: %APPDATA%/gcloud/application_default_credentials.json
    • others: $HOME/.config/gcloud/application_default_credentials.json
  4. If running in Google App Engine, the built-in service account associated with the application will be used.

  5. If running in Google Compute Engine, the built-in service account associated with the virtual machine instance will be used.

  6. If you want to authenticate directly without using a json file, you can specify an array for key_file in disk config with this data:

    'key_file' => [
        'type' => env('GOOGLE_CLOUD_ACCOUNT_TYPE'),
        'private_key_id' => env('GOOGLE_CLOUD_PRIVATE_KEY_ID'),
        'private_key' => env('GOOGLE_CLOUD_PRIVATE_KEY'),
        'client_email' => env('GOOGLE_CLOUD_CLIENT_EMAIL'),
        'client_id' => env('GOOGLE_CLOUD_CLIENT_ID'),
        'auth_uri' => env('GOOGLE_CLOUD_AUTH_URI'),
        'token_uri' => env('GOOGLE_CLOUD_TOKEN_URI'),
        'auth_provider_x509_cert_url' => env('GOOGLE_CLOUD_AUTH_PROVIDER_CERT_URL'),
        'client_x509_cert_url' => env('GOOGLE_CLOUD_CLIENT_CERT_URL'),
    ],
    

Public URLs

The adapter implements a getUrl($path) method which returns a public url to a file.

Note: Method available for Laravel 5.2 and higher. If used on 5.1, it will throw an exception.

$disk = Storage::disk('gcs');
$url = $disk->url('folder/my_file.txt');
>>> http://storage.googleapis.com/bucket-name/folder/my_file.txt

If you configure a path_prefix in your config:

$disk = Storage::disk('gcs');
$url = $disk->url('folder/my_file.txt');
>>> http://storage.googleapis.com/bucket-name/path-prefix/folder/my_file.txt

If you configure a custom storage_api_uri in your config:

$disk = Storage::disk('gcs');
$url = $disk->url('folder/my_file.txt');
>>> http://your-custom-domain.com/bucket-name/path-prefix/folder/my_file.txt

For a custom domain (storage api uri), you will need to configure a CNAME DNS entry pointing to storage.googleapis.com.

Please see https://cloud.google.com/storage/docs/xml-api/reference-uris#cname for further instructions.

Usage

$disk = Storage::disk('gcs');

// create a file
$disk->put('avatars/1', $fileContents);

// check if a file exists
$exists = $disk->exists('file.jpg');

// get file modification date
$time = $disk->lastModified('file1.jpg');

// copy a file
$disk->copy('old/file1.jpg', 'new/file1.jpg');

// move a file
$disk->move('old/file1.jpg', 'new/file1.jpg');

// get url to file
$url = $disk->url('folder/my_file.txt');

// Set the visibility of file to public
$disk->setVisibility('folder/my_file.txt', 'public');


// See https://laravel.com/docs/5.3/filesystem for full list of available functionality
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].