我在命名api提供的pdf时遇到问题。但是即使设置了CONTENT_DISPOSITION,保存窗口中的默认名称也始终是download.pdf。 尝试过 1. mediaType = application / pdf和MediaType.APPLICATION_OCTET_STREAM_VALUE。 2.附着后有一定的空间;
@RequestMapping(value = "manifestpdf/{logId}" ,method = RequestMethod.GET/*,produces =MediaType.APPLICATION_OCTET_STREAM_VALUE*/)
public ResponseEntity<InputStreamResource> getManifestPdf(@RequestHeader(value = HEADER_TENANT_ID) String Id,@PathVariable("logId") String logsId){
S3ObjectInputStream response = Services.getManifestPdf(Id,logId);
return ResponseEntity.ok().contentType(MediaType.valueOf("application/pdf"))
//.header("Content-Disposition","attachment; filename=testing.pdf")
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=manifest.pdf")
.header(HttpHeaders.CACHE_CONTROL,"no-cache")
.body(new InputStreamResource(response));
我尝试进行的下载的名称是manifest.pdf。有人请帮忙。
谢谢!