View Source Buckets.Location (Buckets v1.0.0-rc.3)

Represents a storage location for a Buckets.Object.

The config field can be either:

  • A keyword list with adapter configuration
  • A Cloud module atom that implements the Buckets.Cloud behaviour

Summary

Functions

Gets the configuration from a Location.

Creates a new Location struct with the given path and configuration.

Types

@type t() :: %Buckets.Location{config: Keyword.t() | module(), path: String.t()}

Functions

@spec get_config(t()) :: Keyword.t()

Gets the configuration from a Location.

If the config is a keyword list, returns it as-is. If the config is a Cloud module, calls the module's config/0 function.

Creates a new Location struct with the given path and configuration.

Parameters

  • path - The storage path for the object (e.g., "uploads/123/file.pdf")
  • config - Either:
    • A keyword list with adapter configuration
    • A Cloud module atom that implements the Buckets.Cloud behaviour

Examples

# With explicit configuration
location = Location.new("uploads/file.pdf", [
  adapter: Buckets.Adapters.S3,
  bucket: "my-bucket",
  region: "us-east-1"
])

# With Cloud module reference
location = Location.new("uploads/file.pdf", MyApp.Cloud)

Returns

A %Buckets.Location{} struct with the path and configuration set.