fileupload onBeforeUpload should be fired before appending files to FormData #1489

merged 1 commit into from Dec 7, 2016


None yet

4 participants

radarsu commented Dec 2, 2016

Issue #1332

In documentation onBeforeUpload event is described:
Callback to invoke before file upload begins to customize the request such as adding header and post parameters.

But some frameworks require post parameters to be appended to FormData before files.

When onBeforeUpload event emits xhr and FormData, there is no way to "prepend" any data to FormData object, so some backend frameworks will return errors like this:
Unable to expose body parameter `exampleParameter` in streaming upload! Client tried to send a text parameter (exampleParameter) after one or more files had already been sent. Make sure you always send text params first, then your files. (In an HTML form, it's as easy as making sure your text inputs are listed before your file inputs.

@cagataycivici cagataycivici added this to the 1.0.2 milestone Dec 7, 2016
@cagataycivici cagataycivici self-assigned this Dec 7, 2016
@cagataycivici cagataycivici merged commit 55ab75a into primefaces:master Dec 7, 2016

This way I can't call setRequestHeader() anymore since it has to be done after


uhm I think they should split this up in two events because now I can't call setRequestHeader() anymore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment