PhoenixKit.Modules.Storage.Library (phoenix_kit v2.40.1)

Copy Markdown View Source

A storage library: a partition of the file store (V202).

Every file, media folder and folder link belongs to exactly one library. System libraries are site-wide and managed by admins; everything that existed before V202 lives in the default one, Media (PhoenixKit.Modules.Storage.Libraries.media_uuid/0). User libraries (V203) belong to a user, are private, and may have members (PhoenixKit.Modules.Storage.LibraryMember). A trashed user library may outlive its owner (owner_uuid NULL) until it is purged.

key_prefix is the first segment of the object key for files stored in the library from now on. nil keeps the historical layout, which is what Media uses, so nothing about an existing install's keys changes.

Go through PhoenixKit.Modules.Storage.Libraries rather than this schema.

Summary

Functions

A new system library: a name, a URL slug and an object-key prefix.

A new user library: a name, its owner, a URL slug (unique among the owner's libraries) and an object-key prefix. Always private.

Renames a library. Its kind, owner and key prefix never change here.

The slug a name gives: lower-case letters and digits, hyphen-separated ("Brand Assets 2026" → "brand-assets-2026"). Letters outside ASCII are dropped with their accents where they have one; a name with nothing left is "library".

Types

t()

@type t() :: %PhoenixKit.Modules.Storage.Library{
  __meta__: term(),
  inserted_at: DateTime.t() | nil,
  is_default: boolean(),
  key_prefix: String.t() | nil,
  kind: String.t(),
  name: String.t() | nil,
  owner: term(),
  owner_uuid: UUIDv7.t() | nil,
  settings: map(),
  slug: String.t() | nil,
  trashed_at: DateTime.t() | nil,
  updated_at: DateTime.t() | nil,
  uuid: UUIDv7.t() | nil,
  visibility: String.t()
}

Functions

create_system_changeset(library, attrs)

A new system library: a name, a URL slug and an object-key prefix.

create_user_changeset(library, attrs)

A new user library: a name, its owner, a URL slug (unique among the owner's libraries) and an object-key prefix. Always private.

rename_changeset(library, attrs)

Renames a library. Its kind, owner and key prefix never change here.

slugify(name)

@spec slugify(String.t()) :: String.t()

The slug a name gives: lower-case letters and digits, hyphen-separated ("Brand Assets 2026" → "brand-assets-2026"). Letters outside ASCII are dropped with their accents where they have one; a name with nothing left is "library".