i am start learn JS, my server give me file with encoding windows-1251
return ResponseEntity
.ok()
.contentType(MediaType.parseMediaType(determinateContentType(request, res)))
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + res.getFilename() + "\"")
.body(res);
@NotNull
private String determinateContentType(@NotNull HttpServletRequest request, @NotNull Resource resource) {
String contentType;
try {
String absolutePath = resource.getFile().getAbsolutePath();
contentType = request.getServletContext().getMimeType(absolutePath);
} catch (IOException e) {
log.error("Wrong file URL", e);
throw new NotFoundException("Wrong file URL", e.getCause());
}
if (contentType == null) {
contentType = "application/octet-stream";
}
return contentType;
}
if i download file with Postman- all good,but i add button :
async downloadValidationReport(): Promise<void> {
const result = await http.post<string>(await getExportValidationResultUrl(), this.preparePayload(), {
headers: { 'Content-Type': 'application/json' }
});
const file = new Blob([result], { type: 'text/csv' });
saveAs(file, 'validation.csv');
}
And this is problem: file come in with hieroglyphs like this: Çîíà çàñòðîéêè èíäèâèäóàëüíûìè æèëûìè äîìàìè" I need help, what can I do? Where does the encoding change take place? I will be grateful for your help