I'm currently working on a small Spring-based web application with an AngularJS frontend. One can upload and download files to it, which are mirrored to some other storage. If I download a file, the application checks if all replicas are there and valid, and if not it re-uploads the file to the storage with a corrupted copy of the file.
The thing I want to achive is, that when I download the file, I want to be able to additionally transfer data about the replicas. More specifically, I want to state to the user, if the file was coruppted somewhere and had to be uploaded. And if so, where this happened.
The code I'm currently using is (I know that it's not very efficient to download from all providers everytime):
public ResponseEntity downloadFile(@RequestParam("fileName") String filename) {
*) Download the file from each storage
*) Check if all replicas are ok
*) If not find the corrupted ones and reupload the file
*) Get one of the OK copies and store it in byte array named "file"
*) Create some headers and store them in a variable named "headers"
return new ResponseEntity<>(file, headers, HttpStatus.OK);
}
What I want to know is:
Is it possible to return something that holds some additional information about the corrupted replicas and which is still handled by the browser like a normal file? So instead of returning a byte array, I would return some other magical object that holds the content of the file, with some additional data?