You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to do some pre-processing (for example, checking the to-be-uploaded image width and height and giving an error if the size is not correct) before I upload a file directly to S3, so I need a way to make the upload fail with a meaningful error instead of a generic one.
Elixir version (elixir -v): Elixir 1.14.0 (compiled with Erlang/OTP 23)
Phoenix version (mix deps): 1.7.0
Phoenix LiveView version (mix deps): 0.18.16
Operating system: Pop-OS 22.10
Browsers you attempted to reproduce this bug on (the more the merrier): Firefox
Does the problem persist after removing "assets/node_modules" and trying again? N/A
I have also been looking into this, as I wanted to be able to log errors with client uploads to S3 for troubleshooting reasons.
As far as I can tell, the error reason given to entry.error in your example is sent back to the server, but then not stored anywhere. You can see this in update_progress in Phoenix.LiveView.Upload: reason is not stored.
This was previously noticed as a side issue in issue #1478, with a comment here from @chrismccord that there is "very little you can do on the server if the client fails and we must hold the error reason in memory".
Perhaps in your case you could handle displaying the error messages from pre-processing directly on the client via JavaScript rather than sending the error message via the server. For logging errors, I was considering pushing a custom failure message to the server from the Uploader.
But it would be helpful for there to be a way to access these errors, maybe through a separate external_client_errors list on UploadConfig. This would not be populated if no errors were actually sent by the Uploader JavaScript. Or there could be the option to define a handler function for external client errors on allow_upload.
Environment
I want to do some pre-processing (for example, checking the to-be-uploaded image width and height and giving an error if the size is not correct) before I upload a file directly to S3, so I need a way to make the upload fail with a meaningful error instead of a generic one.
Actual behavior
Looking at the live view documentation here https://hexdocs.pm/phoenix_live_view/uploads-external.html in the upchunk uploader implementation, the function
entry.error
is used to pass an error message as an argument.Because of that, I'm assuming that you can extract that message somehow, but when I try the same thing like this:
I will get the generic
:external_client_failure
when runningupload_errors(@uploads.images, entry)
instead ofmy_error_message
string.Expected behavior
I expect to get
my_error_message
string as the error message.The text was updated successfully, but these errors were encountered: