LiveReactNative.Upload (live_react_native v0.0.3)

View Source

Library-owned, LiveView-shaped mobile upload support (server mode). Mirrors allow_upload/consume_uploads names but is built on Phoenix's patterns, not its private Phoenix.LiveView.Upload* modules. State lives as a plain (non-change-tracked) assign under :__mobile_uploads__; progress is reported client-side, so this state is never diffed to the phone.

Summary

Functions

Register an upload config (call in the LiveView mount, on the socket).

Append a base64 chunk to the entry's temp file.

Consume the DONE entries for name: call fun.(%{path: tmp}, entry) for each, collect the returns, delete the temp files, and drop the entries. Returns {results, socket}.

Delete all staged temp files and clear upload entries (call on channel terminate).

Mark an entry complete.

Validate + open a temp file for an incoming entry. Payload has string keys.

Functions

allow_mobile_upload(socket, name, opts \\ [])

Register an upload config (call in the LiveView mount, on the socket).

append_chunk(socket, ref, data_b64)

Append a base64 chunk to the entry's temp file.

consume_mobile_uploads(socket, name, fun)

Consume the DONE entries for name: call fun.(%{path: tmp}, entry) for each, collect the returns, delete the temp files, and drop the entries. Returns {results, socket}.

discard_all(socket)

Delete all staged temp files and clear upload entries (call on channel terminate).

finish_entry(socket, ref)

Mark an entry complete.

start_entry(socket, payload)

Validate + open a temp file for an incoming entry. Payload has string keys.