View Source Entrepot.Upload protocol (Bonfire v0.9.10-classic-beta.156)

A protocol defining the interface for file uploads.

This protocol should be implemented by any struct that represents an uploadable file.

There are built-in implementations for Plug.Upload, File.Stream,Stream,URIandEntrepot.Locator`.

Summary

Types

t()

All the types that implement this protocol.

Functions

Retrieves the contents of the upload.

Retrieves the name of the upload.

Retrieves the path of the upload, if available.

Types

@type t() :: term()

All the types that implement this protocol.

Functions

@spec contents(struct()) :: {:ok, iodata()} | {:error, String.t()}

Retrieves the contents of the upload.

Returns

  • {:ok, iodata()}: The contents of the upload.
  • {:error, String.t()}: An error message if the contents cannot be retrieved.
@spec name(struct()) :: String.t()

Retrieves the name of the upload.

Returns

  • String.t(): The name of the upload.
@spec path(struct()) :: String.t() | nil

Retrieves the path of the upload, if available.

Returns

  • String.t(): The path of the upload.
  • nil: If no path is available.