An Ecto type for a stored file (Storehouse.File) in a record's column:
a map (jsonb in PostgreSQL) of its key, URL, name, type, size,
checksum, width, height, metadata (Storehouse.Metadata) and analysis
(Storehouse.Analysis, each step's as Storehouse.Analysis.to_map/1). No table of files: the record has its file.
schema "users" do
field :avatar, Storehouse.Ecto.File
field :photos, {:array, Storehouse.Ecto.File}, default: []
end
# The migration
add :avatar, :map
add :photos, {:array, :map}, default: []It casts a Storehouse.File only, never a map of a form's params: a
file's key comes from Storehouse, never from a browser, so that no one
puts another's file in their record. Put files with
Storehouse.Ecto.put_file/4.
A store of the field's own
store: names the store the field's files are kept in (a module of
use Storehouse.S3 or use Storehouse.Local): Storehouse.Ecto makes
them permanent there, deletes them from there, and analyzes them from
there. The default is Storehouse.adapter/0.
field :invoice, Storehouse.Ecto.File, store: MyApp.PrivateFiles
field :scans, {:array, Storehouse.Ecto.File}, store: MyApp.PrivateFiles, default: []
Summary
Functions
The store of a field's files, as init/1 keeps it: a module, or nil.