Lightning.Storage.GCS (Lightning v2.19.0-pre)

View Source

A storage backend module for handling file storage in Google Cloud Storage (GCS).

It implements the Lightning.Storage.Backend behaviour to manage file storage operations in Google Cloud Storage. This includes storing files to GCS buckets and generating signed URLs for secure access to the stored files.

Requests are made against the GCS JSON API directly, with a bearer token from Lightning.Storage.GCS.TokenSource. All object paths are prefixed with the configured STORAGE_PATH before they reach the API.

Responsibilities

  • Storing Files: The store/2 function uploads files from a local source path to a specified destination path within a GCS bucket.
  • Deleting Files: The delete/1 function removes an object from the bucket.
  • Generating Signed URLs: The get_url/1 function generates a signed URL for accessing a file stored in GCS. This signed URL is valid for a limited time (default 1 hour).
  • Configuration: The module relies on application configuration to determine the GCS bucket and Google API connection settings.

Example Usage

# Store a file in GCS
Lightning.Storage.GCS.store("/path/to/source", "destination/path")

# Get a signed URL for the stored file
{:ok, url} = Lightning.Storage.GCS.get_url("destination/path")