PhoenixKit 2.39.0: Private media libraries for users
PhoenixKit 2.39.0 lets a site give its users private media libraries of their own, with members and expiring file links. It also splits profile settings into tabs and stops deleting files when their uploader’s account is deleted.
User libraries
User libraries are off by default. An admin turns them on in the new User libraries card under Settings → Media → Libraries, sets how many each user may own (10 by default) and how long a private link lasts, and sees every user library as owner, members, files, size and trash. A user with the storage permission uses the libraries they own or belong to, and the new storage.create_library permission lets them create one. Members are managers, contributors or viewers.
Users manage their libraries and members on a new Media tab of their profile settings. /admin/libraries lists and opens them for moderation and testing. When an Owner or Admin opens someone else’s library, it is written to the audit log.
A file in a user library is served only through a link that expires, by default after a 12-hour window, and is never kept by shared caches. User library files do not show in the site’s Media or its pickers. Files in the site’s Media are served exactly as before.
Profile settings in tabs
Profile settings now have one address per tab: /profile/settings/account, /security, /sessions, /notifications and /integrations. A tab only shows when it has something for the user, and /profile/settings opens Account. Personal integrations get their own tab.
Safer deletions
Orphan cleanup now moves files to the trash, with the button Move all orphaned to trash, so they can be restored until the daily prune. Deleting a user keeps their uploads in the site’s and other people’s libraries, with no uploader; their own libraries are trashed and purged.
Fixes
Downloads of different sizes of one picture get their own names, such as photo-original.jpg and photo-large.jpg, and save instead of opening in a tab. A crafted address can no longer turn the language redirect into a server error, and the media folder tree no longer shifts on every click.
Upgrading
Run mix phoenix_kit.update for migration V203. It adds a library members table and replaces five constraints, validating each separately so writes are not blocked. Links to the old single profile settings page still open the Account tab.
Full release notes: PhoenixKit 2.39.0
2.39.0 · 25 September 2026
Added
- Storage libraries, phase 2 (migration V203): user libraries. When an
install turns them on (
storage_user_libraries_enabled, off by default), a user with thestoragepermission uses the libraries they own or are a member of, and one with the newstorage.create_librarysub-permission creates them, up tostorage_user_library_limit(default 10). A user library is private and has members: manager, contributor or viewer. The first one a user creates is their default. Trashing one frees its name at once; its files are purged, bytes included, after the trash retention period. New API onStorage.Libraries:create_user_library/2,list_user_libraries/1,get_user_library/2, members (add_member/4,update_member_role/4,remove_member/3),trash_library/2,set_default_library/2,allows?/2. - Where user libraries are managed and used. Settings → Media →
Libraries gains a User libraries card: turn them on, set how many
each user may own and how long a private link lasts, and see every user
library as metadata (owner, members, files, size, trash). Users manage
their libraries and members on a new Media tab of their profile
settings (
/profile/settings/media)./admin/librarieslists and browses them, for holders ofstorage. It is meant for moderation and testing;phoenix_kit_photosis the end-user surface. An Owner or Admin also sees every other user’s library there, below their own, and may open any of them; every opening is written to the audit log (storage.library_opened). - Private serving for user libraries. A file in a private library is
served only with a time-window token: an HMAC over the file, the variant
and an expiry rounded up to a window (
storage_private_url_window_hours, default 12), so a URL stays the same, and cacheable in the browser, within its window. Its permanent token is refused, an expired one is a 403, a public bucket is proxied instead of redirected to, and the response isprivate(never kept by a shared cache). Core’s media pages mint these URLs themselves; a module showing a user library’s file calls the newStorage.authorized_url/4, which checks access first. Files in Media are served exactly as before. - Dedup is per library. The same person may keep the same file in Media and in a library of their own; within one library it is still stored once. Files in Media keep the key they had.
Changed
-
Orphan cleanup moves files to the trash instead of deleting them. The media page’s button is now Move all orphaned to trash, and
mix phoenix_kit.cleanup_orphaned_files --deletedoes the same. An orphan is only a guess (nothing known references the file), so it can be restored from the trash until the daily prune deletes it aftertrash_retention_days. -
Deleting a user no longer deletes the files they uploaded. Their uploads in the site’s libraries and in other people’s stay, with no uploader. The libraries they own are trashed and purged. Before, the file rows went with the user and their bytes were left behind in the buckets. Deleting a user who had ever created a media folder no longer fails either.
-
Profile settings are split into tabs, one URL per tab:
/profile/settings/account,/security,/sessions,/notificationsand/integrations. A tab shows only when it has something for the user; the bare/profile/settingsopens Account. Personal integrations, until now the last section of one long page, are their own tab for holders of theintegrationspermission. Embedding theUserSettingscomponent is unchanged.
Fixed
- A downloaded copy is named for what it is (#872). Downloading three
sizes of one picture used to save
photo.jpg,photo (1).jpgandphoto (2).jpg. Now each gets its own name, with the extension of the stored bytes:photo-original.jpg,photo-large.jpg,photo-large-annotated.jpg, and so on (Storage.download_name/3). The details page’s download links add?dl=1, which makes the response anattachment, also when a bucket answers for it, so the click saves the file instead of opening it in a tab. Its list shows the picture’s sizes and the annotated copies in separate groups, with every other variant after the standard sizes (review fix). A download link whose image was edited in the meantime stays a download (review fix). - A locale redirect can no longer turn a request into a 500 (#863).
The locale plug’s redirect target is now checked whole, with Phoenix’s
own rules, and a segment it builds must be letters, digits,
-or_. Before, an address like/%2509-x/…or/zz/%09evil/shopmade the redirect raise. A target that fails the check renders in the default language instead. - The media folder tree no longer shifts on every click (#873). The loading spinner sits in the icon’s own box, shows only when a reply takes longer than 300 ms, and the tree and the file column keep their scrollbar space, so nothing jumps when a folder opens.
- A user library stays out of the site’s media (review).
/admin/mediaand the media pickers no longer list a user library’s files, and the file detail page uses the same read check as the file info API, so holdingmediais not enough to open one.get_public_urlno longer returns a public bucket’s object URL for a private file. Deep-zoom tiles of a private file are cachedprivate, the same as the file itself, so a shared cache cannot keep them after the link expires. Orphan cleanup leaves a user library’s files alone, and so does “Delete all orphaned” inside a user library: nothing in the site references them, so they looked unreferenced and would have been deleted. A viewer of a shared library can no longer open its member list by sending the event.
Migration notes
- V203 adds
phoenix_kit_storage_library_membersand replaces five constraints in place: the uploader FK onphoenix_kit_filesand the creator FK onphoenix_kit_media_foldersbecomeON DELETE SET NULL, the files CHECK accepts a file with a library, and the library owner FK becomesSET NULLwith a check that lets only a trashed user library lose its owner. Each is addedNOT VALIDand validated in its own statement, so the scans do not block writes. It also repeats V202’s slug statements, which a database that ran an early build of V202 needs (#871); elsewhere they change nothing.
PhoenixKit 2.39.0. Install or update: {:phoenix_kit, "~> 2.39"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.