View Source Lightning.Storage.Local (Lightning v2.10.4)

A storage backend module for handling local file storage.

It implements the Lightning.Storage.Backend behaviour to manage file storage operations on the local file system. This includes storing files from a source path to a destination path and generating URLs for accessing stored files.

Responsibilities

  • Storing Files: The store/2 function is responsible for copying files from a given source path to a specified destination path on the local file system.
  • Generating URLs: The get_url/1 function generates a file:// URL for accessing a stored file locally.
  • Configuration: The module relies on application configuration to determine the root directory for storage operations.

Example Usage

# Store a file
{:ok, filename} =
  Lightning.Storage.Local.store("/path/to/source", "destination/path")

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