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

  1. Add buckets to your dependencies:

     def deps do
       [{:buckets, "~> 1.0.0-rc.2"}]
     end
  2. Create a Cloud module:

     defmodule MyApp.Cloud do
       use Buckets.Cloud, otp_app: :my_app
     end
  3. Configure your adapter:

     # config/dev.exs
     config :my_app, MyApp.Cloud,
       adapter: Buckets.Adapters.Volume,
       bucket: "priv/uploads",
       base_url: "http://localhost:4000"
  4. 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:

See the adapter modules for specific configuration options.

Next Steps

Summary

Functions

Delegates a delete/2 function call to the configured :adapter.

Delegates a get/2 function call to the configured :adapter.

Delegates a put/3 function call to the configured :adapter.

Delegates a url/2 function call to the configured :adapter.

Functions

Link to this function

delete(remote_path, config)

View Source

Delegates a delete/2 function call to the configured :adapter.

Link to this function

get(remote_path, config)

View Source

Delegates a get/2 function call to the configured :adapter.

Link to this function

put(object, remote_path, config)

View Source

Delegates a put/3 function call to the configured :adapter.

Link to this function

url(remote_path, config)

View Source

Delegates a url/2 function call to the configured :adapter.