Commit 046a0b5782e4ae832e6fb73824a560b0499d53e3
1 parent
70be3b70
1、修正UploadFileServiceImpl.java的upload方法,设置url时不要使用Paths生成URL,因为这个时http访问url,不是本地…
…存储路径url,在windows下斜杠会反,所以改成直接拼接字符串
Showing
1 changed file
with
1 additions
and
1 deletions
src/main/java/com/bsth/luban_springboot2/service/impl/UploadFileServiceImpl.java
| ... | ... | @@ -58,7 +58,7 @@ public class UploadFileServiceImpl implements UploadFileService { |
| 58 | 58 | uploadFile.setExt(uploadFile.getName().substring(uploadFile.getName().lastIndexOf("."))); |
| 59 | 59 | uploadFile.setMime(file.getContentType()); |
| 60 | 60 | uploadFile.setSize(Double.toString(file.getSize() / 1000)); |
| 61 | - uploadFile.setUrl(Paths.get(upload_file_url_prefix, uploadFile.getHash()).toString()); | |
| 61 | + uploadFile.setUrl(upload_file_url_prefix + "/" + uploadFile.getHash().toString()); | |
| 62 | 62 | |
| 63 | 63 | try { |
| 64 | 64 | File localFilePath = Paths.get(uploadPath, uploadFile.getHash() + uploadFile.getExt()).toFile(); | ... | ... |