Here is my problem - The response data is a binary representation of a tar.gz file.
These data are generated from the following Java code (A REST Endpoint logic ) from the server:
public ResponseEntity<InputStreamResource> downloadLogs(String nodeName, String storagePoolName){
ResponseEntity<InputStreamResource> responseEntity = null;
File initialFile2 = new File("C:\\Users\\Admin\\Downloads\\logs\\pz_logs_temp.tar.gz");
InputStream targetStream = FileUtils.openInputStream(initialFile2);
//Preparing Response
InputStreamResource resource = new InputStreamResource(targetStream);
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.add(HttpHeaders.CONTENT_DISPOSITION, "attachment");
responseHeaders.add("filename", String.format("%s.tar.gz",nodeName));
responseEntity = ResponseEntity.ok()
.headers(responseHeaders)
.contentType(MediaType.APPLICATION_OCTET_STREAM)
.body(resource);
return responseEntity;
}
This is the picture on the Java Script side:
This is how the data looks in console:
This is a response headers
The code generates a tar.gz file and downloads it. However, the generated file is not a valid tar.gz file. I could not open it.
I think I am missing something on the Java Script side.


