Folder-scoped file attachments for a project, backed by core
PhoenixKit.Modules.Storage — the workspace's per-resource-folder
convention (phoenix_kit_staff.Attachments is the reference this
mirrors): no module-owned table, no migration.
Each project owns a deterministic root folder project-<uuid>, resolved
by name on every read (never cached on the project row, so renames or
deletions in /admin/media can't strand a dangling uuid) and created lazily
on first use. Core's [:name, :parent_uuid] unique index makes
find-or-create race-safe. Files live in core phoenix_kit_files — a file
is IN the folder either as its home (file.folder_uuid) or via a
FolderLink. Removal follows core's non-destructive convention:
soft-trash a sole-home file, promote a link on a shared one, drop the
link on a linked-only one — never hard-delete a possibly-shared asset.
Summary
Functions
Links picked/uploaded files into the project folder: a homeless file gets
this folder as home; a file homed elsewhere gains a FolderLink
(idempotent per file).
Public download URL, nil-safe.
Find-or-create the project folder. Race-safe: a lost create re-resolves the winner via the unique index.
Heroicon name for a file's type (template helper).
Deterministic root folder name for a project's files.
Resolves the project folder uuid WITHOUT creating it (render-safe).
Active files in the project folder (home or linked), newest first, capped.
Removes a file from the project folder. Home here + not linked elsewhere → soft-trash (recoverable in the media trash); home here + linked elsewhere → promote a link to home; linked-only here → drop the link.
Functions
Links picked/uploaded files into the project folder: a homeless file gets
this folder as home; a file homed elsewhere gains a FolderLink
(idempotent per file).
@spec download_url(PhoenixKit.Modules.Storage.File.t()) :: String.t() | nil
Public download URL, nil-safe.
Find-or-create the project folder. Race-safe: a lost create re-resolves the winner via the unique index.
Heroicon name for a file's type (template helper).
Deterministic root folder name for a project's files.
Resolves the project folder uuid WITHOUT creating it (render-safe).
@spec list_files(binary()) :: [PhoenixKit.Modules.Storage.File.t()]
Active files in the project folder (home or linked), newest first, capped.
Removes a file from the project folder. Home here + not linked elsewhere → soft-trash (recoverable in the media trash); home here + linked elsewhere → promote a link to home; linked-only here → drop the link.