Emerge.Config.RuntimePaths (Emerge v0.5.1)

Copy Markdown View Source

Allow images from outside your application's priv/ directory. Set this record as Emerge.Config.Assets.runtime_paths. This controls runtime image paths, not your application's general filesystem access.

%Emerge.Config{
  assets: %Emerge.Config.Assets{
    runtime_paths: %Emerge.Config.RuntimePaths{
      enabled: true,
      allowlist: ["/data/photos"]
    }
  }
}

Fields

  • enabled — false by default. Set true to allow runtime sources such as {:path, "/data/photos/photo.jpg"}; an allowlist is also required.
  • allowlist — allowed absolute directory roots; defaults to [], allowing no runtime files. Keep the list as narrow as possible.
  • follow_symlinks — false by default, rejecting symlink path components. With true, resolved paths must still fall within an allowed directory.
  • max_file_size — positive encoded-file size limit in bytes; defaults to 25_000_000. This does not limit decoded image dimensions or peak memory.
  • extensions — allowed filename extensions, including their leading dot. Defaults to [".png", ".jpg", ".jpeg", ".webp", ".gif", ".bmp", ".svg"]. The list replaces these defaults when supplied.

Logical application assets do not need this opt-in. All fields require a new viewport to change. See Use assets for source syntax.

Summary

Types

Canonical form after nested keyword records have been expanded.

Typed keyword shorthand accepted in this record's parent field.

t()

Types

normalized_t()

@type normalized_t() :: t()

Canonical form after nested keyword records have been expanded.

options()

@type options() :: [
  enabled: boolean(),
  allowlist: [String.t()],
  follow_symlinks: boolean(),
  max_file_size: pos_integer(),
  extensions: [String.t()]
]

Typed keyword shorthand accepted in this record's parent field.

t()

@type t() :: %Emerge.Config.RuntimePaths{
  allowlist: [String.t()],
  enabled: boolean(),
  extensions: [String.t()],
  follow_symlinks: boolean(),
  max_file_size: pos_integer()
}