PHP code example of websight / l5-google-cloud-storage

1. Go to this page and download the library: Download websight/l5-google-cloud-storage library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

websight / l5-google-cloud-storage example snippets


   Websight\GcsProvider\CloudStorageServiceProvider::class,
   

  'gcs' => [
      // Select the Google Cloud Storage Disk
      'driver'         => 'gcs',
      // OPTIONAL: The location of the json service account certificate, see below
      // 'credentials' => storage_path('my-service-account-credentials.json'),
      // OPTIONAL: The GCP project id, see below
      // 'project_id'  => 'my-project-id-4711',
      // The bucket you want this disk to point at
      'bucket'         => 'my-project-id-4711.appspot.com',
  ],
  

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

// Put a private file on the 'gcs' disk which is a Google Cloud Storage bucket
$disk->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
$disk->put(
    'test-public.png',
    file_get_contents(storage_path('app/test-public.png')),
    \Illuminate\Contracts\Filesystem\Filesystem::VISIBILITY_PUBLIC
);

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