-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LiveView Native Clients: Support file uploading #15
LiveView Native Clients: Support file uploading #15
Comments
According to @simlay and @bcardarella it is blocked by #16 : replied to a thread: bcardarella sebastian.imlay bcardarella sebastian.imlay bcardarella export default class EntryUploader { sebastian.imlay bcardarella bcardarella 3 replies bcardarella |
Handle uploads as described in https://hexdocs.pm/phoenix_live_view/uploads.html.
This will be a port of phoenixframework/phoenix_live_view#1184 and any subsequent fixes.
From analysis of the
phoenix_live_view
js
, it appears that the uploads are chunked and chunks are sent to a speciallvu:*
namespacehttps://github.com/phoenixframework/phoenix_live_view/blob/45bd9bd23dcd4524a328950f511ff30f8382c4dd/assets/js/phoenix_live_view/entry_uploader.js#L12
On joining this channel, the next chunk is read
https://github.com/phoenixframework/phoenix_live_view/blob/45bd9bd23dcd4524a328950f511ff30f8382c4dd/assets/js/phoenix_live_view/entry_uploader.js#L24-L42
And the chunk is pushed
https://github.com/phoenixframework/phoenix_live_view/blob/45bd9bd23dcd4524a328950f511ff30f8382c4dd/assets/js/phoenix_live_view/entry_uploader.js#L36-L54
The percentage progress is pushed by the calle to
this.entry.progress
if the push of the"chunk"
event is OKhttps://github.com/phoenixframework/phoenix_live_view/blob/45bd9bd23dcd4524a328950f511ff30f8382c4dd/assets/js/phoenix_live_view/upload_entry.js#L45-L61
The
pushFileProgress
both updates the element locally and pushes the progress to the server, allowing server-side changes of the progresshttps://github.com/phoenixframework/phoenix_live_view/blob/45bd9bd23dcd4524a328950f511ff30f8382c4dd/assets/js/phoenix_live_view/view.js#L877-L887
This server-side channels and event handling of those channels does and should not change for native. While the framework
lvu:*
channels handle the chunks, any"progress"
events can be optionally handled by the LiveView on the server, but it is not required as shown in the guide.The text was updated successfully, but these errors were encountered: