View Source Buckets (Buckets v1.0.0-rc.3)
Cloud-agnostic file storage for Elixir with Phoenix integration.
Buckets provides a unified API for working with file storage across different cloud providers. Whether you're using local filesystem storage for development, Google Cloud Storage, Amazon S3, or other S3-compatible providers, Buckets offers a consistent interface with powerful features.
Features
- Multiple Storage Adapters - Support for filesystem, Google Cloud Storage, Amazon S3, and S3-compatible providers (Cloudflare R2, DigitalOcean Spaces, Tigris)
- Direct Uploads - Upload files directly from browsers to cloud storage, bypassing your Phoenix server
- Signed URLs - Generate time-limited, secure URLs for private files
- LiveView Integration - Seamless integration with Phoenix LiveView's file upload functionality
- Dynamic Configuration - Switch storage providers at runtime for multi-tenant applications
- Development Tools - Built-in router for local file uploads/downloads during development
- Telemetry - Comprehensive instrumentation for monitoring and debugging
Quick Start
Add
buckets
to your dependencies:def deps do [{:buckets, "~> 1.0.0-rc.2"}] end
Create a Cloud module:
defmodule MyApp.Cloud do use Buckets.Cloud, otp_app: :my_app end
Configure your adapter:
# config/dev.exs config :my_app, MyApp.Cloud, adapter: Buckets.Adapters.Volume, bucket: "priv/uploads", base_url: "http://localhost:4000"
Upload files:
# From a Plug.Upload or Phoenix.LiveView.UploadEntry {:ok, object} = MyApp.Cloud.insert(upload) # From a file path object = Buckets.Object.from_file("photo.jpg") {:ok, stored} = MyApp.Cloud.insert(object) # Generate a signed URL {:ok, url} = MyApp.Cloud.url(stored, expires: 3600)
Storage Adapters
Buckets includes these built-in adapters:
Buckets.Adapters.Volume
- Local filesystem storageBuckets.Adapters.S3
- Amazon S3 and S3-compatible servicesBuckets.Adapters.GCS
- Google Cloud Storage
See the adapter modules for specific configuration options.
Next Steps
- See
Buckets.Cloud
for the high-level API - See
Buckets.Object
for working with file objects - Read the Getting Started guide
- Learn about Direct Uploads with LiveView