Plug.Upload

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:

  • :path - the path to the uploaded file on the filesystem
  • :content_type - the content type of the uploaded file
  • :filename - the filename of the uploaded file given in the request

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.

Summary

Types

t()

Functions

random_file(prefix)

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

random_file!(prefix)

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

start_link()

Starts the upload handling server

Types

t()

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

Functions

random_file(prefix)

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.

random_file!(prefix)

random_file!(binary) :: binary | no_return

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

start_link()

Starts the upload handling server.

© 2013 Plataformatec
Licensed under the Apache License, Version 2.0.
https://hexdocs.pm/plug/1.3.0/Plug.Upload.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部