Even though content-disposition has proper file name , but local downloaded file has different name

154 Views Asked by At

From UI to backend getting a call of type xhr, and from the backend sending the file, with one important response header as below

Content-Disposition: attachment; filename=abc_0714_844G_4_2023Jul14_045451.csv

but when we check the file name which is downloaded to local, we see different file name. why this happening?

our backend java code in spring rest controller.

File file = reportGeneratorService.generateReport(migrationId, orgId);

return ResponseEntity.ok()
            .header("Content-Disposition", "attachment; filename=" + file.getName())
            .contentLength(file.length())
            .contentType(MediaType.parseMediaType(CSV_FILE_CONTENT_TYPE))
            .body(new FileSystemResource(file));

We tried to research, but nothing useful found related to this

0

There are 0 best solutions below