Skip to content

[Upload] Provide single event with all rejected files #8375

@guygoldwasser

Description

@guygoldwasser

Description

B"H
Hi,
assuming developer block usage to pdf types only,
but customer enforce selections to take lets say 4 file that are not pdf.
rejection event will happened 4 times.
the AllFinished event will happened if and only if at least single file path the validations.

But, what i really want is a single generation of error.
e.g. I have my own error dialog, and i don't want to open it 4 times, only once.
I don't see how I can reach it with current.

consistently get AllFinished event might help in such case.
is there any other way to acheve same?

Expected outcome

A single final event knowing all done,

Minimal reproducible example

upload.addFileRejectedListener(event -> {
			if (failMessage == null) {
				failMessage = Lists.newArrayList();
			}
			failMessage.add(event.getFileName() + " - " + event.getErrorMessage());
		});
upload.addAllFinishedListener(event ->{
			if(failMessage == null || failMessage.isEmpty()) {
				logger.debug("All files uploaded successfully.");
				//do what need to do
			} else {
				logger.warn("Some files failed to upload: {}", String.join(", ", failMessage));
				//e.g.  my notification showError("...", failMessage);
				failMessage = null;
			}
		});

Steps to reproduce

  1. create upload with multiply
  2. restrict for some type e.g. application/pdf
  3. load few jpg files

Environment

Vaadin version(s):
OS:

Browsers

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions