@GetMapping("/download")
    ResponseEntity<InputStreamResource> downladFile() throws IOException {

        FileSystemResource file =new FileSystemResource("H:/个人简历/s.png");
        HttpHeaders httpHeaders = new HttpHeaders();
        httpHeaders.setCacheControl("no-cache,no-store,must-revalidate");
        httpHeaders.setContentType(MediaType.IMAGE_JPEG);
        httpHeaders.setContentLength(file.contentLength());
        httpHeaders.setContentDispositionFormData("attachment", URLEncoder.encode("妹妹.jpg","utf-8"));
        return ResponseEntity.ok()
                .headers(httpHeaders)
                .body(new InputStreamResource(file.getInputStream()));
    }

 

相关文章:

  • 2022-12-23
  • 2021-04-03
  • 2021-10-14
  • 2021-06-10
  • 2021-11-28
  • 2022-12-23
猜你喜欢
  • 2021-09-24
  • 2021-12-10
  • 2021-05-18
  • 2021-07-04
  • 2022-12-23
  • 2022-12-23
  • 2021-08-21
相关资源
相似解决方案