You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I upload file, and then remove it via remove button in interface, the file stays in MultiFileMemoryBuffer.
Steps to reproduce
MultiFileMemoryBuffer buffer = new MultiFileMemoryBuffer();
Upload upload = new Upload(buffer);
add(upload);
Button btn = new Button("Save");
btn.addClickListener(e -> {
System.out.println(buffer.getFiles().size());
});
add(btn);
So, upload file, then delete it, and then click the Save button. System console will print '1'.
The text was updated successfully, but these errors were encountered:
lolytxd
changed the title
Files stay in MultiFileMemoryBuffer after clicking the remove button in interface
Bug - Files stay in MultiFileMemoryBuffer after clicking the remove button in interface
Jun 27, 2018
To my knowledge this does not happen automatically - you need to register UploadAbortEvent listener to get notified at BE the file was removed in the UI.. However this event listener - and some others event listeners as well - do not work well at the moment, please see vaadin/vaadin-upload-flow#57. There is a workaround mentioned in the comments to this issue, which allows you to detect which file was removed at BE and you can use it to clean up received files.. but I guess you will need to extend also MultiFileMemoryBuffer to make this happen
This is true for all receivers/buffers and quite deceptive as the expectation is that the file will be removed again, like the clear button on a Vaadin TextField. And the listener required to work around this is also still missing in the Java API (#1342). Please finish implementing this component. There are so many workarounds necessary to use it.
For completenes sake, the same applies to MultiFileBuffer (which stores files on disk), as well as all custom implementations of MultiFileReceiver, as there is currently no way for the receiver to know that a file has been removed. You would need to listen on the remove event from outside the receiver, where you have a handle on the upload component.
So we probably need an aditional method on the receiver that is called by the upload component whenever a file is removed. And the existing receivers should implement that method to fix this issue.
Vaadin version: 10.0.0
Description
When I upload file, and then remove it via remove button in interface, the file stays in MultiFileMemoryBuffer.
Steps to reproduce
So, upload file, then delete it, and then click the Save button. System console will print '1'.
The text was updated successfully, but these errors were encountered: