Question

I have a fileUploader widget that I'm using to select an xml file. I then have a button that calls my handler in the viewImpl class when the user submits the selected file. If I understand things correctly, from there I do a submit from the formPanel and the file is on the server.

@UiHandler("calculateComplexityButton")
    void onClickCalculateComplexity(ClickEvent e){
        formPanel.submit();
        //How do I get the inputStream back to here????
        presenter.getTask(inputStream);
    }

My problem is how do I get the inputStream off the server? I tried using an RPC call for all this, but when I try to get the inputStream I'm not pulling anything off the server. I tried:

inputStream = request.getInputStream();

but it appears to be empty. Any ideas on this?

I dropped the RPC code and used a simple HTTPRequest I found here. That gets me to the servlet, but the request doesn't have the file stream. When I reach this line in the code:

FileItemIterator iter = upload.getItemIterator(request); //Nothing is here in iter.
Was it helpful?

Solution

You can not make an upload via RPC, thats why you have to submit your form to a servlet.

final FormPanel form = new FormPanel();
form.setEncoding(FormPanel.ENCODING_MULTIPART);
form.setMethod(FormPanel.METHOD_POST);
form.setAction("/upload");

So, when you do form.submit() it will send your file to the Action(Servlet). In the server side you can use the lib form apache (commons-fileupload). You have many different way to get your file, you can save on disk, read on memory....

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top