管理端富文本上传代码移植
This commit is contained in:
parent
c3d39648e8
commit
b2451f91e9
@ -6,6 +6,7 @@ import com.xinelu.common.core.domain.AjaxResult;
|
||||
import com.xinelu.common.utils.StringUtils;
|
||||
import com.xinelu.common.utils.file.FileUploadUtils;
|
||||
import com.xinelu.common.utils.file.FileUtils;
|
||||
import com.xinelu.common.utils.file.MimeTypeUtils;
|
||||
import com.xinelu.framework.config.ServerConfig;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -19,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
@ -37,6 +39,8 @@ public class CommonController {
|
||||
|
||||
@Autowired
|
||||
private ServerConfig serverConfig;
|
||||
@Resource
|
||||
private XinELuConfig xinELuConfig;
|
||||
|
||||
private static final String FILE_DELIMETER = ",";
|
||||
|
||||
@ -147,4 +151,23 @@ public class CommonController {
|
||||
log.error("下载文件失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用管理端富文本上传请求(单个)
|
||||
*/
|
||||
@PostMapping("/richTextPictureUrl")
|
||||
public AjaxResult richTextPictureUrl(MultipartFile file) throws Exception {
|
||||
// 上传文件路径
|
||||
String filePath = XinELuConfig.getProfile() + xinELuConfig.getRichTextPictureUrl();
|
||||
// 上传并返回新文件名称
|
||||
String fileName = FileUploadUtils.uploadNurseStationPath(filePath, file, MimeTypeUtils.IMAGE_EXTENSION);
|
||||
//拼接路径
|
||||
String url = serverConfig.getUrl() + fileName;
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("url", url);
|
||||
ajax.put("fileName", fileName);
|
||||
ajax.put("newFileName", FileUtils.getName(fileName));
|
||||
ajax.put("originalFilename", file.getOriginalFilename());
|
||||
return ajax;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user