Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

How to clear the file list on an Upload component

Francois Dumas
4 years ago Aug 29, 2018 12:44pm
Ronny Edler
4 years ago Aug 30, 2018 8:46am
Artur Signell
4 years ago Aug 30, 2018 9:11am

According to https://github.com/vaadin/vaadin-upload/issues/128 you should do upload.files = []; which can be done from Java as

upload.getElement().setPropertyJson("files", Json.createArray());

There does not seem to be any Java API available for it. Maybe waiting for a propery JavaScript API (https://github.com/vaadin/vaadin-upload/issues/184)

Francois Dumas
4 years ago Aug 30, 2018 11:48am
Dmitriy Sosnovich
4 years ago Sep 03, 2018 4:24pm
Youness Teimouri
4 years ago Nov 05, 2018 2:18am

I know this thread is all about clearing, but just as a reference, here is an example to pre-populate the Upload component in Java:

	Upload upload = ...
    JsonArray jsonArray = Json.createArray();
    JsonObject jsonObject = Json.createObject();
    jsonObject.put("name", "filename.txt");
    jsonObject.put("progress", 100);
    jsonObject.put("complete", true);
    jsonArray.set(0, jsonObject);
    upload.getElement().setPropertyJson("files", jsonArray);

https://vaadin.com/components/vaadin-upload/html-examples/upload-advanced-demos

Last updated on Nov, 5th 2018
Martin Vyšný
9 months ago Oct 27, 2021 7:25am