Allow default uploader when using external uploaders in LiveView - #3801
Open
nallwhy wants to merge 3 commits into
Open
Allow default uploader when using external uploaders in LiveView#3801nallwhy wants to merge 3 commits into
nallwhy wants to merge 3 commits into
Conversation
SteffenDE
force-pushed
the
allow_default_uploader_when_using_external_uploaders
branch
from
August 14, 2026 14:46
9adf4c5 to
7d797d3
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates Phoenix.LiveView.Upload to allow an external: &fun/2 preflight to selectively fall back to the built-in channel uploader (via {:ok, :default, socket}), enabling mixed upload strategies within a single upload configuration.
Changes:
- Extend external preflight handling to accept
{:ok, :default, socket}and return a signed channel upload token for that entry. - Refactor upload consumption to support consuming a mix of channel-uploaded and externally-uploaded entries under the same upload config.
- Add unit + E2E coverage demonstrating mixed default/channel and external uploaders.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/phoenix_live_view/upload/external_test.exs | Adds coverage for external preflight returning :default to use built-in uploader. |
| test/e2e/tests/uploads.spec.js | Adds E2E scenario mixing default and external uploaders in one form submission. |
| test/e2e/test_helper.exs | Adds a test external uploader implementation and an external upload endpoint for E2E tests. |
| test/e2e/support/upload_live.ex | Adds mixed-upload LiveView behavior and renders uploader type for assertions. |
| lib/phoenix_live_view/upload.ex | Implements :default fallback for external preflight and refactors consumption to handle mixed entries. |
| lib/phoenix_live_view/test/upload_client.ex | Updates test upload client to handle external entries (meta map tokens) and mixed uploads. |
| lib/phoenix_live_view/test/live_view_test.ex | Uses a unified upload client start path for external and channel uploads. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In the current implementation of Phoenix.LiveView.Upload, when you configure external: &function/2, it becomes mandatory to specify an uploader.
This makes sense in most cases, but there’s an important limitation: Once you introduce even a single external uploader, you lose the ability to fall back to the default built-in uploader.
This can be problematic when you want to mix different uploader strategies depending on the file — for instance, using a custom external uploader for images, but sticking to the built-in uploader for PDFs or other files.
I’ve patched LiveView locally to support falling back to the default uploader even when external: &function/2 is set — and it works well in my testing.
If simply returning
:defaultfor the uploader in meta seems inappropriate.https://elixirforum.com/t/allow-default-uploader-when-using-external-uploaders-in-liveview/70501