I have a download button in the UI, user clicks on it and download 3 files in a zip format.
It’s not necessary that the files are arleady there when download button is clicked because the backend process can take sometime to put the files at a particular location on the server.
Files are going to be in following format
file1_1555077233.csv file2_1555077233.csv file3_1555077233.csv
So that each time a user clicks on the button, I can get the latest file based on the timestamp.
I am trying to figure out where exactly I should generate this timestamp?This timestamp is going to be included with the file name at the time of file generation.
The problem with this approach is that how would I know the timestamp value if a user shuts down his computer and come back later looking for files after clicking the download button ?
2) Should I have my back end java based webservice generate the timestamp as soon as it’s called from the UI?
The problem with this approach is that I will need access to this timestamp on the UI side so that when a user clicks on the download button, I can make a request based on the file name and let the user know whether the file exists or not. One approach is to get this timestamp from the Java webservice in json response but this would only work when the user keeps the browser open for long time which is not ideal. Let’s say user shuts down everything and come back later. How should I handle this thing ?
If there’s any additional thing I would need to do(which I think I would have to) in addition to handling timestamp generation, please let me know. Thanks
Clarification on what I am looking for:
Meaning of the phrase
so that UI is aware of the file name it's going to provide the user. from my comment.
Let’s say UI makes an Ajax call to a Java webservice. UI sends some parameters in the POST request which starts a stored procedure on the back end. I generate a timestamp in milliseconds on the Java side. When it comes to generating CSV file on the Java side, I would generate it like this :
This file will exist somewhere on the server.
Now, on the UI side, I would need to know this number 156788898 (timestamp in milliseconds), then only, I would be able to get this file from the location. I am trying to uniquely identify the file which got generated recently and tied to that particular user.
One solution I could think of is:
Let’s say if , after generating timestamp on the Java side, I send it back to the browser as a JSON response. I can store it in HTML5 storage as localStorage or sessionStorage but if a user shuts down his/her computer and then decide to come back, how do I figure out the latest files associated with a particular user? Since, I won’t be having way of tracking this number 156788898 because the HTML Storage would be wiped out after computer restart. Not sure if HTML5 storage is a good way to go about it or not.