Flysystem Google Cloud Storage provides a Google Cloud Storage plugin
for Flysystem. This plugin allows you to replace the local file system with Google
Storage
. Flysystem GCS can be used as the default file system or can be configured
for each file/image field separately.

Requirements

Upload the Service Account JSON file to your site by following these steps:

  1. Create a project in GCP.
  2. Go to the storage browser and create a bucket.
  3. Create a Service Account and get private key:
    • Go to the Service Accounts page.
    • Create Service Account with Storage Admin role.
    • Create a new key for the Service Account (key type - JSON).
    • Download the JSON file to a private folder in your site.

This module requires the following dependencies:

Installation

Install as you would normally install a contributed Drupal module. For further
information, see Installing Drupal Modules.

Configuration

Stream wrappers are configured in settings.php (see the Flysystem README.md).

Example configuration

$settings['flysystem'] = [
  'cloud-storage' => [
    'driver' => 'gcs',
    'config' => [
      'bucket' => 'example',
      'keyFilePath' => '/serviceaccount.json',
      'projectId' => 'google-project-id',
      // More options: https://googlecloudplatform.github.io/google-cloud-php/#/docs/google-cloud/v0.46.0/storage/storageclient?method=__construct.
      // Optional local configuration; see https://github.com/Superbalist/flysystem-google-cloud-storage#google-storage-specifics.
      '_localConfig' => [
        'prefix' => 'extra-folder/another-folder/',
        // Change part of URLs from https://storage.googleapis.com/[bucket_name]/extra-folder/another-folder/ to https://cname/.
        'uri' => 'https://cname',
      ],
    ],
    'cache' => true, // Cache filesystem metadata.
  ],
];

After this, make sure to apply the following configuration changes to your Drupal installation:

  • Change the default download method for File system at /admin/config/media/file-system.
  • Change the upload destination for existing fields.
Supporting organizations: 

Project information

Releases