So in my vaadin project I have the following lines of code:
final String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();
//dummy file to be overwritten before download starts
Resource myResource = new FileResource(new File(basepath + "/WebContent/WEB-INF/text.txt"));
//initialize file downloader
fileDownloader = new FileDownloader(myResource) {
@Override
public boolean handleConnectorRequest(VaadinRequest request, VaadinResponse response, String path)
throws IOException {
//create new file which is then to be downloaded
StreamResource s = new StreamResource(new StreamSource() {
@Override
public InputStream getStream() {
return new ByteArrayInputStream(FileUtils.readFileToByteArray(FileUtils.getFile(basepath
+ "/WebContent/WEB-INF/space.jpg")));
}
}, "space.jpg");
fileDownloader.setFileDownloadResource(s);
return super.handleConnectorRequest(request, response, path);
}
};
fileDownloader.extend(button_download);
When running the program however, it won’t let me download
space.jpg
. Instead, it lets me download some other random file (example.rdf) which I had worked with an hour ago. Clearly the changes in the source code since then are not taking any effect.
What to do?