0

I have a spring boot application that uses spring-web and embedded tomcat.

The app has a REST URI where a tar file will be posted to. The tar file will have a number of .csv files. The tar will be kept in a persistent data store for later retrieval.

When a user requests (using another REST API) to view the content of the tar, the application will

  1. fetch the relevant tar file from the database
  2. untar the relevant tar file into a randomly generated new directory inside system /tmp dir
  3. generate HTML pages (one for each csv) which has some bootstrap and other css involved for better UI look of the CSV data in tabular form
  4. and should be able to serve those pages.
  5. when the user logs off or after a certain time period of inactivity the randomly generated /tmp dir should be removed

Note that the additional requirement multiple users can access this server and upload/view different tar files at the same time and hence the need for creating a new temporary directory.

Questions:

  1. How to achieve the ability to serve dynamically generated HTML pages inside a random temp directory that is outside the scope of server's web-inf?
  2. Is it possible to achieve the same if I create temp directories inside the context path?
  3. How to achieve this for concurrent users trying to access different directories respectively?
  4. Are there any suggestions on a better way to design what I intend to do with the application here?
João Dias
  • 16,277
  • 6
  • 33
  • 45
  • Just don't. Create a basic HTML and supply the model-data and let Spring (with Thymeleaf for instance) generate the HTML on the fly. No need to make it more complex. The only thing that is different is the model-data between the request. Where that data comes from (database, filesystem or your tar file) doesn't matter. – M. Deinum Oct 20 '20 at 07:19
  • thanks. but I'm still not able to figure out how to supply the .csv files outside the web app context (say, somewhere in /tmp dir) as a "model" to the thymeleaf or for any view component – karthik s Oct 23 '20 at 08:42
  • unzip, read content and pass that as a regular model to your pages as you would when you retrieve something from a database. – M. Deinum Oct 23 '20 at 08:44
  • Thanks @M.Deinum. This helped – karthik s Dec 11 '20 at 10:28

0 Answers0