Upload file - run once

(Sorry for bad title - it is download :slight_smile: )
Hi I have a problem.
I was doing this example; https://vaadin.com/wiki/-/wiki/Main/Letting%20the%20user%20download%20a%20file
And I have a code like this

    raportButton = new Button("Generuj Fakture");
    raportButton.setDescription("Generuje Fakture na podstawie wpisów");
    raportButton.setIcon(resourceGenerateInvoice);
   
    FileDownloader fileDownloader = new FileDownloader(createResource());
    fileDownloader.extend(raportButton);
    ...

private Resource createResource() {
return new StreamResource(new StreamSource() {
@Override
public InputStream getStream() {

                RaportyDAO raportyDAO = new RaportyDAO();
                
                raportyDAO.generateRaport(taskList, "admin", dateOdField.getValue(), dateDoField.getValue());
                
                ByteArrayOutputStream fileExcelBytesArrayOS = new ByteArrayOutputStream();
               
                ....(actions)............
                
                return new ByteArrayInputStream(fileExcelBytesArrayOS.toByteArray());
            }
        }, "Raporty.xlsx");
    }

AND It run only once, data has changed and it behave like it has cached somewhere an old file and sugest me to download only first version of generated file …

What can be wrong ?
In debug mode it even dont go to getStream() method in second time … just straight to download old file.

Your resource is indeed created only once, when you create the file downloader.
Try to follow the second part of the wiki page:
Lazily determine the content and the name of the file being server
.

Thank You it works : D