Answer the question
In order to leave comments, you need to log in
How to catch an error when downloading a file from a single page application?
In a single-page application for downloading files, I redirect to a URL that gives the content of the file, content0disposition: attachment, the file offers to save, while the browser remains on the original page. Things are good.
But sometimes the file is not ready yet, and then I return the status 204 No Content instead of the file - and just nothing happens. In the body of the response I give an error message, but it does not get anywhere.
How can I get the 204 response body from the original page?
Or what is the best way to organize the case of a missing file during a redirect? It is necessary that the browser stays on the page so as not to break the application.
Option to make additional request before downloading, checking if there is a file - not ice, an extra request. At the very least, I'll stop there.
Answer the question
In order to leave comments, you need to log in
Look for information about XHR2, the "blob" response type, create a link on the client to the generated object from the received blob, and figure out how the user can follow (or follow) this link.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question