|
|
@ -3,7 +3,6 @@ package com.ruoyi.file.controller; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
@ -22,12 +21,6 @@ public class SysFileController |
|
|
|
{ |
|
|
|
{ |
|
|
|
private static final Logger log = LoggerFactory.getLogger(SysFileController.class); |
|
|
|
private static final Logger log = LoggerFactory.getLogger(SysFileController.class); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 上传文件存储在本地的根路径 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Value("${file.path}") |
|
|
|
|
|
|
|
private String localFilePath; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private ISysFileService sysFileService; |
|
|
|
private ISysFileService sysFileService; |
|
|
|
|
|
|
|
|
|
|
@ -40,7 +33,7 @@ public class SysFileController |
|
|
|
try |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
|
// 上传并返回访问地址
|
|
|
|
// 上传并返回访问地址
|
|
|
|
String url = sysFileService.uploadFile(file, localFilePath); |
|
|
|
String url = sysFileService.uploadFile(file); |
|
|
|
SysFile sysFile = new SysFile(); |
|
|
|
SysFile sysFile = new SysFile(); |
|
|
|
sysFile.setName(FileUtils.getName(url)); |
|
|
|
sysFile.setName(FileUtils.getName(url)); |
|
|
|
sysFile.setUrl(url); |
|
|
|
sysFile.setUrl(url); |
|
|
|