Storage.Attachment (PhoenixContribStorage v0.1.0)
View SourceProvides macros for adding file attachments to Ecto schemas.
This module allows you to easily add file attachment functionality to your Ecto schemas, similar to Rails ActiveStorage.
Usage
defmodule MyApp.User do
use Ecto.Schema
use Storage.Attachment
schema "users" do
field :name, :string
has_one_attached :avatar
has_many_attached :documents
end
end
This will add virtual fields and helper functions for managing attachments.
Summary
Functions
Attaches multiple blobs to a record.
Attaches a single blob to a record.
Checks if a record has any attachments for the given name.
Detaches all attachments for a given name without deleting the blobs.
Detaches a single attachment without deleting the blob.
Gets all attachments for a record.
Gets a single attachment for a record.
Defines a has_many_attached relationship.
Defines a has_one_attached relationship.
Purges all attachments and their blobs for a given name.
Functions
Attaches multiple blobs to a record.
Attaches a single blob to a record.
Checks if a record has any attachments for the given name.
Detaches all attachments for a given name without deleting the blobs.
Detaches a single attachment without deleting the blob.
Gets all attachments for a record.
Gets a single attachment for a record.
Defines a has_many_attached relationship.
Defines a has_one_attached relationship.
Purges all attachments and their blobs for a given name.