Bubbling errors from POST route hit from Liveview

At this point, I would suggest you rethink the design of your web app so as to keep as much of your logic as possible in the liveview and only offload the file transfer to the non-liveview part of your app.

There is a similar question to which I already proposed a solution. You can check out the details here: With Liveview, what is best way to download a file to the user's browser? (redirect through Phoenix Controller and back to Liveview, or use a background Task?) - #2 by trisolaran

Summary: generate the file as a response to a liveview event. If the file generation fails, render the error in your liveview. If it succeeds, place the generated file in your application’s priv/static folder and render a download link in your liveview. The dowlonad will be handled by Plug.Static so you won’t need to write any custom controller for it. Of course, now you won’t need to use PubSub anymore :slight_smile:

This is something I implemented recently in one of my projects, and I found this approach to work well.