vaadin / vaadin-upload-flow

Vaadin Flow Java API for vaadin/vaadin-upload Web Component
https://vaadin.com/components/vaadin-upload
Other
7 stars 17 forks source link

FinishedListener is never called #77

Closed Artur- closed 5 years ago

Artur- commented 6 years ago
        Upload upload = new Upload((MultiFileReceiver) (filename, mimeType) -> {
            File file = new File(new File("uploaded-files"), filename);
            try {
                return new FileOutputStream(file);
            } catch (FileNotFoundException e1) {
                e1.printStackTrace();
                return null;
            }
        });
        upload.addStartedListener(e -> {
            System.out.println("Handling upload of " + e.getFileName() + " ("
                    + e.getContentLength() + " bytes) started");
        });
        upload.addFinishedListener(e -> {
            System.out.println("Handling upload of " + e.getFileName() + " ("
                    + e.getContentLength() + " bytes) finished");
        });

        add(upload);

Only prints started messages and never finished messages

ttsanton commented 5 years ago

Hello, I'm encountering the same issue with all three (Started/Finished/Succeeded) Listeners. They are not called when an upload is being submitted. I am currently using the Started/Finished Listeners to verify an image upload is being made and a Succeeded Listener to return a preview of the image.

It also appears that the MemoryBuffer, even though set to the Upload when initialized, is returning a null/empty value.

MemoryBuffer buffer = new MemoryBuffer();
Upload imgUpload = new Upload(buffer);
...
imgUpload.addStartedListener(e -> {
     System.out.println("Handling upload of " + e.getFileName() + " (" + e.getContentLength() + " bytes) started");
});
imgUpload.addFinishedListener(e -> {
     System.out.println("Handling upload of " + e.getFileName() + " (" + e.getContentLength() + " bytes) finished");
});
imgUpload.addSucceededListener(e -> {
     System.out.println("Succeeded Upload of " + e.getFileName());
     //use the MemoryBuffer to stream preview
     try {
          System.out.println("----Upload Primary Image");
          System.out.println(buffer.getFileData().getMimeType());
          BufferedImage img = ImageIO.read(buffer.getInputStream());
          showDbImage(img);
     } catch (IOException ex) {
          _MainUI.getApi().logError(ex);
     }
});
macAtNordea commented 5 years ago

It seems like in StreamReceiverHandler::doHandleMultipartFileUpload, line 178 the upload iterator that is returned from getItemIterator is actually empty.

ttsanton commented 5 years ago

I also want to confirm that this is still an issue in 13.0.0.alpha1

KrifaYounes commented 5 years ago

how to fix that on vaadin10.0.11 ?

KrifaYounes commented 5 years ago

can you release a vaadin10.0.12 with the fix please ?