Feature Request: sap.m.upload.Uploader - add error event upon failed uploads
Currently, sap.m.upload.Uploader will always trigger uploadComplete event regardless of the returned status code. Can please provide any means to identify whether the upload was successful or not?
Code from Uploader.prototype.uploadItem:
oXhr.onreadystatechange = function() {
var oHandler = that._mRequestHandlers[oItem.getId()];
if (this.readyState === window.XMLHttpRequest.DONE && !oHandler.aborted) {
that.fireUploadCompleted({
item: oItem
});
}
};
Hi jcailan, Didn't you get sap.m.upload.Uploader#events/uploadAborted if the upload fails? regards Knut
Hi @KnutThies
No, it didn't trigger. That event only gets triggered when I click on that terminate button in the UI -- see screenshot below:

Additionally, I need the response payload to get the error/success information so that I can reflect the status in the UI. Something like below:

Just to make this work, I was forced to hack the _mRequestHandlers property to get the xhr instance that made the request. If there was an API provided for that, then the hack can be avoided.
See below workaround logic:
onUploadCompleted: function(oEvent) {
var oItem = oEvent.getParameter("item"),
oUploader = oItem.getParent().getUploader(),
oXhr = oUploader._mRequestHandlers[oItem.getId()].xhr;
oItem.setUploadState(UploadState.Complete);
if (oXhr.status === 200) {
addStatus(oItem, "uploadCompleted", true);
setData(oItem, JSON.parse(oXhr.response));
} else {
addStatus(oItem, JSON.parse(oXhr.response));
oItem.setVisibleEdit(false);
}
},
Thanks and regards, Jhodel
Hi @jcailan , Thank you for sharing your enhancement proposal. I've created an internal incident 2180423858. The status of the issue will be updated here in GitHub. Regards, Florian
Hi @flovogt,
Thanks for bringing this up.
After internal discussions, we understood that this issue should be addressed as development request and hence created backlog item FIORITECHP1-21292 in our internal Jira.
Regards, Keerthi G
Fixed with 0ae3992a09d3f2b03c1df5ae5730fe5c8d765d97 and available as of 1.98.0.