学习开发记录:
文件的下载还有问题
@GetMapping("/download/{fileName}")标签:outputStream,11.18,filePath,fileName,download,日记,out From: https://www.cnblogs.com/zhangmingmkzj/p/17841609.html
public void download(@PathVariable String fileName, HttpServletResponse response) throws IOException {
String filePath =ROOT_PATH+File.separator+fileName;
System.out.println(filePath);
if(!FileUtil.exist(filePath)){
System.out.println("无法访问");
return;
}
byte[] bytes = FileUtil.readBytes(filePath);
ServletOutputStream outputStream=response.getOutputStream();
outputStream.write(bytes);
outputStream.flush();
outputStream.close();
}
我想应该是限权的问题,今天修改一下