in reply to Sending file as "TEXT" or "BLOB"
The correct solution here is to use the HTTP status code. This is why HTTP responses include a status code.
If the file exists, the server returns 200 OK and the file as application/zip. If the file does not exist, the server returns 404 Not Found. The client then distinguishes based on this.status: 200 for a BLOB is included and 404 for an error.
Here are the relevant bits of the revised JavaScript: (obviously untested)
xhttp.onreadystatechange = function() { if (this.readystate == 4) { if (this.status == 200) { if (xhttp.responseType == 'blob') { // existing goofy file download code here } else { // report internal error } } else if (this.status = 404) { // report error here } } }
As for the Perl code on the server side, you did not provide a SSCCE, so I can give only a broad outline of how the server processing should work:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sending file as "TEXT" or "BLOB"
by haukex (Archbishop) on Feb 25, 2021 at 06:54 UTC |