GWT fileupload, file not sent to POST

I am struggling with simple file downloads using the GWT 2.4 + gwtupload 0.6.4 library.

Here is the relevant part of my ui.xml dialog:

<g:DialogBox modal="true" width="400px" height="150px"> <g:caption><ui:msg>Import new..</ui:msg></g:caption> <g:VerticalPanel styleName="full-width"> <g:InlineLabel styleName="formlabel"><ui:msg>File name</ui:msg></g:InlineLabel> <up:Uploader ui:field="uploader" validExtensions="zip" styleName="uploader full-width"> </up:Uploader> <g:Button styleName="button" ui:field="importButton" enabled="true"> <ui:msg>Import</ui:msg> </g:Button> 

importButton calls uploader.submit() in the end. My problem is that the first time I press the button and an empty POST is sent to the server and I am returning an error message. If I press the button a second time, my file will be sent correctly. If I close the dialog and start, the same thing will happen. Each import attempt following the first is in order.

Here is an empty POST example:

 Content-Type: multipart/form-data; boundary=---------------------------9003259118762 Content-Length: 46 -----------------------------9003259118762-- 

I tried to press the button a second time as a workaround. However, if I catch the received error message and call uploader.submit() again or even call it from the Timer() callback, it does not work when I click the mouse a second time.

Do you have any ideas what might be wrong?

+4
source share
1 answer

The solution was that some lines after uploader.submit() had a call to uploader.setEnabled(false) . After removing it, the bootloader began to work normally. :-)

+1
source

Source: https://habr.com/ru/post/1403895/


All Articles