Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug - Files stay in MultiFileMemoryBuffer after clicking the remove button in interface #1343

Open
lolytxd opened this issue Jun 27, 2018 · 3 comments
Labels
enhancement New feature or request vaadin-upload

Comments

@lolytxd
Copy link

lolytxd commented Jun 27, 2018

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

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'.

@lolytxd 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
@TomiZet
Copy link

TomiZet commented Jul 18, 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

@vaadin-bot vaadin-bot transferred this issue from vaadin/vaadin-upload-flow Oct 6, 2020
@vaadin-bot vaadin-bot transferred this issue from vaadin/vaadin-upload May 19, 2021
@vaadin-bot vaadin-bot transferred this issue from vaadin/web-components May 21, 2021
@vaadin-bot vaadin-bot added enhancement New feature or request vaadin-upload labels May 21, 2021
@Frettman
Copy link

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.

@mperktold
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request vaadin-upload
Projects
None yet
Development

No branches or pull requests

5 participants