PhoenixKit.Storage.Bucket (phoenix_kit v1.6.15)
View SourceSchema for storage provider configurations.
Buckets represent storage locations where files can be stored. They can be:
- Local filesystem storage
- AWS S3 buckets
- Backblaze B2 buckets
- Cloudflare R2 buckets
Priority System
priority = 0(default): Random selection, prefer most empty drivepriority > 0: Specific priority (1 = highest, 2 = second, etc.)
Fields
name- Display name for the bucketprovider- Storage provider: "local", "s3", "b2", "r2"region- AWS region or equivalent (nullable)endpoint- Custom S3-compatible endpoint (nullable)bucket_name- S3 bucket name (nullable)access_key_id- Encrypted credentials (nullable)secret_access_key- Encrypted credentials (nullable)cdn_url- CDN endpoint for file serving (nullable)enabled- Whether bucket is activepriority- Selection priority (0 = random/emptiest)max_size_mb- Maximum storage capacity in MB (nullable = unlimited)
Examples
# Local storage bucket
%Bucket{
name: "Local SSD",
provider: "local",
enabled: true,
priority: 0,
max_size_mb: 512_000 # 500 GB
}
# AWS S3 bucket
%Bucket{
name: "Production S3",
provider: "s3",
region: "us-east-1",
bucket_name: "my-app-files",
access_key_id: "AKIA...",
secret_access_key: "...",
cdn_url: "https://cdn.example.com",
enabled: true,
priority: 1 # Highest priority
}
# Backblaze B2 bucket
%Bucket{
name: "Backup B2",
provider: "b2",
endpoint: "s3.us-west-002.backblazeb2.com",
bucket_name: "my-backup-bucket",
access_key_id: "...",
secret_access_key: "...",
enabled: true,
priority: 2
}
Summary
Functions
Changeset for creating or updating a bucket.
Returns whether this bucket is a cloud storage bucket (S3, B2, R2).
Returns whether this bucket is a local storage bucket.
Types
@type t() :: %PhoenixKit.Storage.Bucket{ __meta__: term(), access_key_id: String.t() | nil, bucket_name: String.t() | nil, cdn_url: String.t() | nil, enabled: boolean(), endpoint: String.t() | nil, file_locations: [PhoenixKit.Storage.FileLocation.t()] | Ecto.Association.NotLoaded.t(), id: UUIDv7.t() | nil, inserted_at: NaiveDateTime.t() | nil, max_size_mb: integer() | nil, name: String.t(), priority: integer(), provider: String.t(), region: String.t() | nil, secret_access_key: String.t() | nil, updated_at: NaiveDateTime.t() | nil }
Functions
Changeset for creating or updating a bucket.
Required Fields
nameprovider(must be one of: "local", "s3", "b2", "r2")
Validation Rules
- Provider must be valid
- Priority must be >= 0
- Quality must be between 1-100 (if provided)
- S3/B2/R2 buckets require credentials
Returns whether this bucket is a cloud storage bucket (S3, B2, R2).
Returns whether this bucket is a local storage bucket.