exfile v0.3.6 Exfile.Ecto.File View Source

An Ecto.Type used to handle files persisted to the store backend.

Link to this section Summary

Functions

Casts a recognizable value to an %Exfile.File{} and uploads it to the cache backend

Dumps an %Exfile.File{} struct to the file URI, suitable for storage in the database

Loads a file URI from the database and returns an %Exfile.File{} struct representing that file

The Ecto type

Uploads a file from the cache backend to the store backend

Link to this section Functions

Casts a recognizable value to an %Exfile.File{} and uploads it to the cache backend.

Accepts five patterns:

  • An %Exfile.File{} stored in the cache or store backends
  • An %Exfile.File{} stored in a different backend
  • An %Exfile.LocalFile{}
  • A %Plug.Upload{}
  • A string URI representing a file from an arbitrary backend

The string URI can be used to upload a file that is currently stored in a separate backend. The format is:

exfile://[backend name]/[file ID]

Dumps an %Exfile.File{} struct to the file URI, suitable for storage in the database.

Loads a file URI from the database and returns an %Exfile.File{} struct representing that file.

Supports loading a plain ID for backwards compatibility.

Uploads a file from the cache backend to the store backend.

This function should be called after the record has been successfully saved to the database and all validations are passing.