我有一个使用java中的spring框架下载文件(txt,.doc,*.csv(的API。
这是我的代码
@RequestMapping(path = "/download", method = RequestMethod.GET)
public ResponseEntity<Resource> download(String param) throws
IOException {
InputStreamResource resource = new InputStreamResource(new FileInputStream(file));
return ResponseEntity.ok()
.headers(headers)
.contentLength(file.length())
.contentType(MediaType.parseMediaType("application/octet-stream"))
.body(resource);
}
请参阅此示例中的第 16 行upload.feature
这是一个正常的get