I am still searching around this subject, but I cannot find a simple solution, and I don't sure it doesn't exist.
Part 1
I have a service on my application that's generating an excel doc, by the dynamic DB data.
public static void notiSubscribersToExcel(List<NotificationsSubscriber> data) { //generating the file dynamically from DB's data String prefix = "./src/main/resources/static"; String directoryName = prefix + "/documents/"; String fileName = directoryName + "subscribers_list.xlsx"; File directory = new File(directoryName); if (! directory.exists()){ directory.mkdir(); // If you require it to make the entire directory path including parents, // use directory.mkdirs(); here instead. } try (OutputStream fileOut = new FileOutputStream(fileName)) { wb.write(fileOut); fileOut.close(); wb.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }
Part 2
I want to access it from the browser, so when I call it will get downloaded. I know that for the static content, all I need to do is to call to the file, from the browser like that:
http://localhost:8080/documents/myfile.xlsx
After I would be able to do it, all I need is to create link to this url from my client app.
The problem - Currently if I call to the file as above, it will download only the file which have been there in the compiling stage, but if I am generating a new files after the app is running the content won't be available.
It seems that the content is (as it's called) "static" and cannot be changed after startup.
So my question is
- is there is a way to define a folder on the app structure that will be dynamic? I just want to access the new generated file.
BTW I found this answer and others which doing configuration methods, or web services, but I don't want all this. And I have tried some of them, but the result is the same.
FYI I don't bundle my client app with the server app, I run them from different hosts