phoenix_live_view icon indicating copy to clipboard operation
phoenix_live_view copied to clipboard

No way to cancel external upload

Open balexand opened this issue 8 months ago • 1 comments

Environment

  • Elixir version (elixir -v): 1.16.3
  • Phoenix version (mix deps): 1.7.12
  • Phoenix LiveView version (mix deps): 0.20.14
  • Operating system: Mac OS (latest)
  • Browsers you attempted to reproduce this bug on (the more the merrier): Chrome
  • Does the problem persist after removing "assets/node_modules" and trying again? Yes/no: yes

Actual behavior

I'm doing video upload to Mux using the UpChunk library as described in https://hexdocs.pm/phoenix_live_view/uploads-external.html. I can cancel the upload by calling Phoenix.LiveView.cancel_upload/3. This clears the upload entry in the live view but it doesn't cancel the client-side upload. The upload continues to run and consume bandwidth until it completes or until the browser is refreshed.

Expected behavior

I would expect there to be a way to cancel an external upload in a way that stops the upload in the browser. This could be implemented as a callback in the external upload JS that would get called when the upload is cancelled. That callback could then call the abort function in UpChunk or in the XHR. The upload guide does something like this with the onViewError callback but this callback is only called when there is a view error, not when the upload is cancelled.

balexand avatar Jun 05 '24 23:06 balexand