exfile v0.3.6 Exfile.ProcessorChain View Source

A module to run a chain of processors on a file.

Link to this section Summary

Link to this section Types

Link to this type definition() View Source
definition() :: name | {name, args} | {name, args, opts}
Link to this type opts() View Source
opts() :: [{:key, any}]
Link to this type uploadable() View Source
uploadable ::
  %Exfile.File{backend: term, backend_meta: term, id: term, meta: term} |
  %Exfile.LocalFile{io: term, meta: term, path: term}

Link to this section Functions

Link to this function apply_processors(processors, uploadable) View Source
apply_processors([], uploadable) :: {:ok, uploadable}
apply_processors([definition, ...], uploadable) ::
  {:ok, Exfile.LocalFile.t} |
  {:error, atom}

Apply a chain of processors to an uploadable.

If the list of processor definitions is empty, it will pass-through the uploadable argument untouched. If the list of processor definitions is not empty, it will coerce the uploadable argument in to a LocalFile, downloading it from the backend if necessary.

The definition list accepts three different terms:

  • A string, representing the processor name to apply
  • A 2-element tuple: {string, list of processor arguments}
  • A 3-element tuple: {string, list of processor arguments, list of processor options}

If a processor encounters an error, the chain is halted and the error is returned immediately in the format {:error, reason}.

Link to this function coerce_to_local_file(local_file) View Source