Inconsistencies in XHRUpload's response handling
See original GitHub issueTrying out Uppy, I’m facing a blocker. I don’t think Uppy forwards me the server response, which means I can’t let the user know what happened if the server rejects the uploaded file.
Here is the code I wrote:
link(scope, elem, attrs) {
const uppy = Uppy({
id: attrs.id,
autoProceed: true,
})
.use(DragDrop, { target: `#${attrs.id}` })
.use(XHRUpload, {
endpoint: `${attrs.url}`,
headers: {
authorization: 'Basic dGVzdDp0ZXN0Cg==',
}
})
.run();
uppy.on('complete', (result) => {
console.log('successful files:', result.successful)
console.error('failed files:', result.failed)
});
}
That console.error gives me one item in result.failed
{
"source": "DragDrop",
"id": "uppy-transfersexport120120181147csv-2493-1515754039000",
"name": "transfers_export_12_01_2018 11_47.csv",
"extension": "csv",
"meta": {
"name": "transfers_export_12_01_2018 11_47.csv",
"type": null
},
"type": null,
"data": {
"fullPath": "/transfers_export_12_01_2018 11_47.csv"
},
"progress": {
"percentage": 100,
"bytesUploaded": 2944,
"bytesTotal": 2944,
"uploadComplete": false,
"uploadStarted": 1515761105337
},
"size": 2493,
"isRemote": false,
"remote": "",
"error": "Upload error"
}
The server answered with
{
"timestamp": "2018-01-12T12:43:18.71",
"status": 422,
"error": "Unprocessable Entity",
"path": "/api/v1/transfers/payload_upload",
"data": "Not a zip file"
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
XMLHttpRequest Send() throws error despite ... - Stack Overflow
I am using XmlhttpRequest to send a POST requests on localhost and chrome developer tools console and network to verify the requests.
Read more >XMLHttpRequest - The Modern JavaScript Tutorial
We can upload/download files, track progress and much more. ... This will be called after the response is received xhr.onload = function() ...
Read more >XMLHttpRequest Standard
To handle response end-of-body for an XMLHttpRequest object xhr , run these steps: Handle errors for xhr . If xhr 's response is...
Read more >XMLHttpRequest.status - Web APIs - MDN Web Docs
The read-only XMLHttpRequest.status property returns the numerical HTTP status code of the XMLHttpRequest 's response.
Read more >XMLHttpRequest vs the Fetch API for Ajax - SitePoint
fetch( 'http://domain/service', { method: 'GET' } ) .then( response => response.json() ) ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
On my side I did not set up the server side route, so I have a 404 error but I can not get an error on my
I have tried this in
getResponseError
:All files are in the
successful
key.We think this was solved, if not, feel free to re-open!