SAP / openui5

OpenUI5 lets you build enterprise-ready web applications, responsive to all devices, running on almost any browser of your choice.
http://openui5.org
Apache License 2.0
2.96k stars 1.24k forks source link

this.fireUploadStart is NOT triggered in FileUploader.js -> FileUploader.prototype.upload = function() #945

Closed Siarhei-Tsikhanenka closed 8 years ago

Siarhei-Tsikhanenka commented 8 years ago

OpenUI5 version: 1.28

Browser/version (+device/version): any

Any other tested browsers/devices(OK/FAIL): all failed

URL (minimal example if possible): n/a, the issue is in FileUploader.js

User/password (if required and possible - do not post any confidential information here): n/a

Steps to reproduce the problem: When UploadCollection control and multiple files selection is used in version 1.28 then even BeforeUploadStarts is not triggered for each file.

The reason is the FileUploader,js does not fire even BeforeUploadStarts, please have a look here:

https://github.com/SAP/openui5/blob/rel-1.28/src/sap.ui.unified/src/sap/ui/unified/FileUploader.js

function :: this.fireUploadStart is triggered in FileUploader.js -> FileUploader.prototype.upload = function() before block :: aXhr[j].xhr.open("POST", this.getUploadUrl(), true); if (this.getHeaderParameters()) { var oHeaderParams = this.getHeaderParameters(); for (var i = 0; i < oHeaderParams.length; i++) { var sHeader = oHeaderParams[i].getName(); var sValue = oHeaderParams[i].getValue(); aXhr[j].xhr.setRequestHeader(sHeader, sValue); aXhr[j].requestHeaders.push({name: sHeader, value: sValue}); } }

after block :: NULL

expected block :: (taken from release 1.30)

var sFilename = aFiles[j].name; var aRequestHeaders = this._aXhr[j].requestHeaders; this.fireUploadStart({ "fileName": sFilename, "requestHeaders": aRequestHeaders }); for (var i = 0; i < aRequestHeaders.length; i++) { // Check if request is still open in case abort() was called. if (this._aXhr[j].xhr.readyState === 0) { break; } var sHeader = aRequestHeaders[i].name; var sValue = aRequestHeaders[i].value; this._aXhr[j].xhr.setRequestHeader(sHeader, sValue); }

We can also see that this part is covered in release 1.30 and higher.

What is the expected result?

Event this.fireUploadStart is triggered in FileUploader.js -> FileUploader.prototype.upload = function()

What happens instead?

Event this.fireUploadStart is NOT triggered in FileUploader.js -> FileUploader.prototype.upload = function(), so in case of multiple files upload all files have the same name as the first one, because there is no way to update file name in the request header parameters set

Any other information? (attach screenshot if possible)

Adjustments to control UploadCollection is currently made by us for Fiori application My Travel and Expenses (MTE).

akudev commented 8 years ago

Hi Siarhei,

when working for SAP, please report issues using the normal internal BCP system. I have opened ticket 1670224349 there for this issue.

Regards Andreas

Siarhei-Tsikhanenka commented 8 years ago

Hi Andreas,

Thank you! I have used this thread this time because that is implementation related we are currently doing, but next time I will use BCP system.

Kind Regards, Siarhei

Stanley-78 commented 8 years ago

Hi Siarhei,

the mentioned UploadStart event was introduced with 1.30 and is therefore not available with 1.28. Unfortunately it's not possible to introduce it in a compatible way by making a fix. The recommendation from my side would be to upgrade to SAP UI5 version 1.36 as a lot of fixes and features needed by the upload collection have been made since then.

Best regards Stanley

Siarhei-Tsikhanenka commented 8 years ago

Hello Stanley,

Thank you for your reply!

Actually, as it's been Go Live blocker for us, we've made a decision to go to 1.36, even that it pushed us to upgrade SAP_BASIS.

Kind Regards, Siarhei

akudev commented 8 years ago

Closing, as this is not a bug, but a not-yet available featrue in an older version, which unfortunately cannot be downported. Sorry for the inconvenience.

Regards Andreas

sush8867 commented 7 years ago

Hi Andreas,

I have encountered a peculiar problem. My Upload Collection is working perfectly fine when I upload a file the first time (Single File upload Multiple = false). But the next time I upload a different file then the fireUploadStart event throws the following error: File upload failed: Cannot instantiate object: "new" is missing!. I am using SAPUI5 version 1.44.1.

Attaching screenshot for your reference. image image

standup-jb commented 7 years ago

I also faced this problem,when i was upload file.I want to get the file name before uplaod.but the fileuploader didn't trigger the function in the controller.so i don't konw how to solve the problem.