Plug.Upload

A server (a GenServer specifically) that manages uploaded files.

Uploaded files are stored in a temporary directory and removed from that directory after the process that requested the file dies.

During the request, files are represented with a Plug.Upload struct that contains three fields:

Note: as mentioned in the documentation for Plug.Parsers, the :plug application has to be started in order to upload files and use the Plug.Upload module.

Source

Summary

random_file!(prefix)

Requests a random file to be created in the upload directory with the given prefix. Raises on failure

random_file(prefix)

Requests a random file to be created in the upload directory with the given prefix

start_link()

Starts the upload handling server

Types

t :: %Plug.Upload{path: Path.t, filename: binary, content_type: binary | nil}

Functions

random_file(prefix)

Specs:

  • random_file(binary) :: {:ok, binary} | {:too_many_attempts, binary, pos_integer} | {:no_tmp, [binary]}

Requests a random file to be created in the upload directory with the given prefix.

Source
random_file!(prefix)

Specs:

  • random_file!(binary) :: binary | no_return

Requests a random file to be created in the upload directory with the given prefix. Raises on failure.

Source
start_link()

Starts the upload handling server.

Source