我正在尝试从Spring端点下载pdf文件。我尝试过:
@RequestMapping("/download_files/{merchant_id}")
public ResponseEntity<byte[]> downloadFile(@PathVariable("merchant_id") Integer merchant_id) throws IOException {
File initialFile = new File("/opt/1/www.pdf");
InputStream in = FileUtils.openInputStream(initialFile);
final HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_PDF);
return new ResponseEntity<byte[]>(IOUtils.toByteArray(in), headers, HttpStatus.CREATED);
}
但是我得到了错误:
2019-08-20 21:02:25,658 INFO [stdout] (default task-307) java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters: /opt/1/25084 BRP (BrookfieldDC.com Site Architecture & Creative?Phase 2) Autoresponders (1).pdf
您知道如何解决此问题吗?