PhoenixKit 3.4.0: Record audio in Phoenix LiveView, resumable uploads and storage quotas
PhoenixKit 3.4.0 adds a microphone recorder any Phoenix LiveView page can use, resumable file uploads that survive a dropped connection, per-user storage quotas, and Hetzner Object Storage support.
Record audio in LiveView without writing JavaScript
The new <.audio_recorder> component gives a page a record button, a timer, a level meter and Send and Cancel buttons. The page declares no upload and writes no JavaScript: it receives a single message with the recording.
<.audio_recorder id="note" format={:wav_16k} />
def handle_info({:audio_recorded, "note", %{data: data, duration: seconds}}, socket) do
# store it, or send it to speech-to-text
end
format={:wav_16k} produces mono 16 kHz WAV, ready for speech-to-text, and the AI module’s new dictation component builds on it.
Uploads that survive a bad connection
Large files now upload in 2 MiB chunks under a signed token, so a pause, a dropped connection or a page reload continues from where it stopped. A new upload manager sends files a few at a time and shows speed, time left and per-file pause, skip and retry. This matters most on phones, where switching to the camera app used to lose the upload.
Storage quotas and more storage providers
Each account can be given a limit on the storage its own user libraries take (“Storage per user” under Settings → Media → Libraries, or your own function per plan), and an upload past it is refused. Hetzner Object Storage is now a built-in provider, and Backblaze B2, which failed for every upload of 5 MB or more and every read, works again. A backup bucket can keep originals only, without the resized copies that can be regenerated.
Settings → Media → Libraries: "Storage per user", here 500 MB.
Hetzner Object Storage as a storage service, with its location and S3 credentials.
Upgrading
Run mix phoenix_kit.update for migration V228 and the new phoenix_kit.js. Resumable uploads are on by default: behind a load balancer, the chunks of one upload must reach the same node, and a test that drives the media browser with render_upload should set storage_resumable_uploads to false.
Full release notes: PhoenixKit 3.4.0
3.4.0 · 6 November 2026
Run mix phoenix_kit.update (V228 and the new phoenix_kit.js).
Added
<.audio_recorder>, a microphone recorder any page can use (PhoenixKitWeb.Components.Core.AudioRecorder, with anAudioRecorderhook inphoenix_kit.js). A button, a timer, a level meter, Send and Cancel, with the upload inside: the page declares noallow_upload, has no hidden form and writes no JavaScript, and gets one message,{:audio_recorded, id, %{data:, format:, content_type:, duration:}}.format={:wav_16k}makes mono 16 kHz WAV in the browser for speech-to-text;format={:native}keeps what the browser recorded. The format, and a WAV’s length, are read from the bytes. It works inside a page’s<form>, with several on one page, and inside a LiveComponent (target={@myself}). It stays hidden where it cannot record. Hosts needmix phoenix_kit.updatefor the newphoenix_kit.js. No migration.- Hetzner Object Storage as a storage service and bucket provider (
hetzner). Its connection form asks for the location (Falkensteinfsn1, Nurembergnbg1, Helsinkihel1) and builds the endpoint<location>.your-objectstorage.com, with the location as the signing region. Buckets are addressed virtual-host style (<bucket>.<location>.your-objectstorage.com), as Hetzner documents. Users may bring their own Hetzner bucket, like any other S3-compatible one. No migration. - A backup bucket of a storage profile can keep originals only (the
profile editor’s “Originals only” on a backup row;
stores: "originals"onProfiles.put_bucket/4): an off-site copy of what cannot be made again, without the sizes, tiles and renders that can. Placement, the reconciler and library verification leave such a bucket out for derived objects, so the copies wanted of a size are capped at the buckets that take one, and sizes already on it are removed by the reconciler. Only a backup may store originals alone: any other role stores everything. This reads thephoenix_kit_storage_profile_buckets.storescolumn again (V205, unused since 2.53.0); a leftoverderivedvalue is treated asall. Changing it makes the profile’s files stale. No migration. - Storage quotas (
Storage.Quotas). An account is charged for the user libraries it owns, whoever uploaded into them: originals plus the sizes and tiles made from them, each file once (a profile’s extra copies are the site’s cost), trash included until purged, libraries on the owner’s own storage excluded. The limit is the newstorage_user_quota_mbsetting (Settings → Media → Libraries, “Storage per user (MB)”;0is none), or a host’s own answer per account (config :phoenix_kit, :storage_quota, {Mod, :fun}returning bytes,nilor:default), for plans.Storage.store_file_in_buckets/7refuses a new file that would take the library’s owner past it with{:error, :quota_exceeded}; a duplicate the uploader already has is never refused, and nothing stored is removed.Quotas.usage/1andQuotas.status/1are for pages that show it. No migration. - An upload manager (
PhoenixKitWeb.Components.Core.UploadManager, withphoenix_kit_upload_manager.js, also carried inphoenix_kit.js), used by the media browser, the selector page and the picker modal. Files wait in the browser and go to LiveView a few at a time: one goes first as a speed probe, and transfers are added while the total speed keeps rising. A panel shows the speed, the time left and a row per file, with pause, skip, upload next, cancel and retry.UploadManager.allow_upload/3sets an upload up in one call, and DOM events (pk-upload:file-done,file-failed,batch-complete) tell a page what happened. Guide:dev_docs/guides/2026-11-02-upload-manager.md. - Resumable uploads (
PhoenixKitWeb.ResumableUpload, at/api/resumable-uploads; settingstorage_resumable_uploads, on by default). A file goes in 2 MiB chunks under a signed token, so a pause, a dropped connection or a reload carries on from the server’s offset. After a reload the browser sends what it still holds by itself, and never a file the server already stored (upload_resume={:auto | :ask}on the media browser). Consume entries withResumableUpload.consume/3. Partial files live inconfig :phoenix_kit, :resumable_upload_dir, so behind a load balancer the chunks of one file must reach the same node. A host’s test that drives the media browser withrender_uploadsetsstorage_resumable_uploadstofalse. - Media settings: Max files per upload (
storage_max_upload_files, default 100, at most 1000; uploads were silently held to 10), Max concurrent uploads (storage_max_concurrent_uploads, default 5, 1 to 20), and editable trash and bucket log retention periods. - A linked Telegram chat can act for its user through the machine API:
Executor.visible_for/3,execute_as/5andredeem_as/6take{:telegram_link, user_uuid, connection_uuid, chat_id}, built only byLinking.actor_ref/2. The link is checked on every call, and the chat has the user’s rights as they stand, narrowed to their default role. It reads, and withallow: :allproposes writes, each held in a confirmation row bound to that chat and bot: a chat reads, turns down and confirms only its own rows, and the person’s site session may act on any of them.Executor.link_writes?/0tells a module the core allows this. The link is dropped on a password change, on signing out other sessions and when an organization is converted. - A feature module can read the site bot all the time.
Linking.handle_updates/3takes its batches,config :phoenix_kit, :telegram_updates_readerkeepspoll/1out of its way, andgetUpdateswaits for the request’s owntimeoutplus ten seconds. New in the client:Telegram.answer_callback_query/3,edit_message_text/5,send_chat_action/4andset_message_reaction/5.SessionRef.scope_for_user/2is the web account gate as a public function. - Opt-in module sub-permissions. A module may declare a sub-permission with
opt_in: true: Admin is then not given it automatically, as with core’s opt-in keys. An existing grant stays until it is revoked. host_*entry points for managed organizations, for a host with its own screens or machine API:ManagedOrganizations.host_create/3,host_convert_to_managed/3andhost_convert_to_independent/3, andOrganizationManagers.host_add/3,host_remove/3andhost_update_contact/3. The host decides who may act; the core recordscreated_by, which must be an active person.- The media browser’s picker takes
allow_move(drag the pick to a folder),subtree_toggle(an “Include subfolders” switch) andper_page. MediaGallerytiles have a menu with Move to trash, through the same removal guard and dialog as the media browser. Hosts need no new wiring.- A guide, “Your App as a Module” (
guides/your-app-as-a-module.md): a host canuse PhoenixKit.Moduleitself.
Changed
Auth.update_user_fields/2andChannelConfig.update/3merge onto the row under a lock, instead of writing back the map of a struct loaded earlier. A stale write could put a dropped Telegram link back.- The installer and
mix phoenix_kit.updateaddimport PhoenixKit.Test.Fixturesto the host’sConnCase, unless a test source already defines one of its names. A fresh Oban block getsnotifier: Oban.Notifiers.PGwhen the repo config looks pooled. - The daisyUI check also reads the git dependency a newer
phx.newdeclares (deps/daisyui/packages/bundle/). - In the media picker, Cancel and Confirm sit in a footer under the grid and stay in view however long the folder is.
- Leaf 0.9 and 0.10 are admitted; the lock has 0.10.1.
Fixed
-
Choosing the first manager of a new managed organization works the way it looks. The Search button only filled a closed dropdown further down the page, so pressing it appeared to do nothing, and a search that found nobody said nothing at all. The page now has one “First manager” picker after the organization’s own fields: clicking it lists people, typing narrows the list, and no match says so. The person search also finds a full name (“Mari Tamm”) and a username, which it never did, and the searches on an organization’s page say when nobody matches.
-
Backblaze B2 works. ExAws 2.7 looks a host up from the region before a caller’s host applies, and raises for a region shaped like AWS’s that AWS does not have, which is every B2 region (
us-west-002,eu-central-003): every request to a B2 bucket failed with “s3 not supported in region … for partition aws”, and checking a B2 connection said “Could not reach the storage endpoint”. S3-compatible requests now go throughStorage.Providers.S3Request: with a host named, the config is built with a region ExAws knows and then signed for the real one, whether the host and region come from the caller or fromconfig :ex_aws. The off-host key store (Integrations.KeyStore.S3) goes through it too. Requests to AWS itself (no host) are unchanged. ExAws’s composite operations (ExAws.S3.upload/4,download_file/3) build the config again for each of their requests, so the S3 provider now does them itself throughS3Request: a file of 5 MB or more goes up in 5 MiB parts, four at a time, and a failed upload is aborted (its parts are no longer left billed on the bucket); a download reads the size, then 8 MiB ranges written in order, and leaves no partial file when it fails. Before, every upload of 5 MB or more to B2 and every read from B2 failed. Verified against real B2 and Hetzner buckets (a 12 MB file there and back, checksums equal) and against a local S3 stub. -
The reconciler’s file lock works behind PgBouncer and for large files (V228). It was a session advisory lock taken on a pooled connection. Behind PgBouncer in transaction pooling, statements outside a transaction may each run on a different server connection, so the unlock could miss the one that took the lock: it stayed held there, and the file was
:skippedfrom then on. And the pool takes back a connection held past its 15 s timeout, so copying a large video (90 MB from one cloud to another) failed the whole batch with “connection is closed”, and a storage move stopped partway. A transaction advisory lock fixes both but pins a server connection for as long as each copy takes, which starved the app’s pool on a move. The lock is now a lease in the file’s row: V228 addsphoenix_kit_files.reconcile_lock_tokenandreconcile_locked_until.Reconciler.with_file_lock/3takes it with one conditionalUPDATE, renews it while it works, gives it back when the work returns or raises, and a holder that dies leaves it to run out (5 minutes). No connection is held meanwhile. A process that holds the lease takes it again (a repair runs the reconciler). Additive migration, catalog-only. -
A dropped connection no longer loses an upload. A file picked while the socket was down was never sent, the manager went dead after a reconnect, and a file cut mid-transfer was reported done and never stored. This matters on phones, where a camera app sends the tab to the background.
-
A file whose processing job fails for good ends as
failed, instead of stayingprocessingfor ever. -
The media selector page and the picker modal follow the site’s upload size limit. They had LiveView’s default of 8 MB.
-
The PDF preview works in Chrome. Its built-in viewer renders nothing in a sandboxed frame, so that one iframe has no sandbox now. A link or form inside the PDF is no longer contained by the frame.
-
repairno longer duplicates an index or key constraint that exists under another name. One of the same structure that no manifest names counts as present and is reported as such. An index left invalid does not count. -
Logout no longer lands on the kit’s mount point. Under
url_prefix, a host with a catch-all route such as/:usernameanswered it, so the visitor reached that host’s “no such user” page. -
A remembered session comes back on every page, through
PhoenixKitWeb.Plugs.Integration, not only on pages that run the kit’s fetch plugs.guides/integration.mdsays how to give the host’s session cookie the same lifetime. -
The permissions matrix can be edited on a phone: its pinned first column covered the whole scroll area.
-
Media tile actions are reachable on touch screens. They only appeared on hover.
i18n
- Every new string is translated in all eight locales.
PhoenixKit 3.4.0. Install or update: {:phoenix_kit, "~> 3.4"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.