Issue
I have a project (Spring Boot, MVC) where:
1. When the button is clicked, a window should open in which the user selects a path, and a newly created file should be exported there to the user's computer. The file is created using object serialization.
2. And in reverse order by another button: file import, deserialization, object acquisition.
I know that this is solved by this form, but I can't figure out exactly how.
<form id="singleUploadForm" name="singleUploadForm">
<input id="singleFileUploadInput" type="file" name="file" class="file-input" required />
<button type="submit" class="primary submit-btn">Submit</button>
</form>
Example of serializing my object with a static save path:
SavedGame savedGame = new SavedGame(info1, info2, info3);
FileOutputStream outputStream = new FileOutputStream("C:\\Users\\Username\\Desktop\\save.ser");
ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream);
objectOutputStream.writeObject(savedGame);
objectOutputStream.close();
I didn't find a solution to this particular problem on the Internet, I only found a lot of such tutorials https://www.callicoder.com/spring-boot-file-upload-download-rest-api-example/ which don't solve my problem directly. Specifically in this I do not understand where to insert my serialized file.
The question: is there any clear tutorial or video on sterilization followed by saving from the web?
I will be very glad of any help! I've been solving the problem for a week now...
Solution
If by 'saving from the web' you mean how can you generate your Serialized file within your Spring app and the allow the user to download the file, this tutorial might be what you're looking for? https://www.baeldung.com/spring-controller-return-image-file
Answered By - Kevin Hooke
Answer Checked By - Mildred Charles (JavaFixing Admin)