Question: So you mean to make this whole code run in batch instead of synchronus?
Answer: I suggested running asynchronously, a batch is just one of the options. For simplicity, we can talk about a batch only.
Question: This File::sendFileToTempStore() will generate a temp URL right?
Answer: Yes, it returns a URL of the file in the temporary storage.
Question: where shall i save it in the DB?
Answer: Where you want; I don't know your business scenario. You can see an example in the standard solution for data export, i.e. data management.
Question: You also said "afterOperation() method of the controller to notify user directly after an asynchronous processing completes but you can't know whether the user session will still be active and the information could get lost."
you mean if the user refreshes the page, it will be lost?
Answer: No, if the user session isn't active anymore (the user closed the browser, the session expired...) there is no way how the user could refresh a page in the non-existing session. This explains why you shouldn't depend on it; you need to store the URL somewhere.
Question: and how to notify the user? i don't think you mean email because if u mean email, what will be the difference if i send the email inside the service class or in afterOperation method in controller?
Answer: You didn't read that carefully. Let me quote myself too: "Then either persist the URL in database, or send it to a user (e.g. by email). In theory, you could utilize afterOperation() method of the controller to notify user directly after an asynchronous processing completes, but [....]".
As you see, I explicitly mentioned email as an option, so it's strange you think I didn't meant that. Also, I never said you should do it in afterOperation(); I explained why you should use one the the two options I suggested (storing the URL or send it to the user) instead of just adding a notificafion (an infolog message) in afterOperation(). Also, this isn't applicable at all if you want talk about a batch only and ignore the other asynchronous modes.