上传地址修改为客户外网地址

main
hshansha 1 month ago
parent f409a7408b
commit f8d08efd94

@ -7,6 +7,7 @@ import javax.servlet.http.HttpServletResponse;
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.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -30,6 +31,8 @@ import com.ruoyi.framework.config.ServerConfig;
public class CommonController public class CommonController
{ {
private static final Logger log = LoggerFactory.getLogger(CommonController.class); private static final Logger log = LoggerFactory.getLogger(CommonController.class);
@Value("${ruoyi.serverUrl}")
private String serverUrl;
@Autowired @Autowired
private ServerConfig serverConfig; private ServerConfig serverConfig;
@ -80,7 +83,9 @@ public class CommonController
String filePath = RuoYiConfig.getUploadPath(); String filePath = RuoYiConfig.getUploadPath();
// 上传并返回新文件名称 // 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file); String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName; // String url = serverConfig.getUrl() + fileName;
//由本机ip地址修改为外网映射地址
String url = serverUrl + fileName;
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = AjaxResult.success();
ajax.put("url", url); ajax.put("url", url);
ajax.put("fileName", fileName); ajax.put("fileName", fileName);

@ -12,6 +12,8 @@ ruoyi:
addressEnabled: false addressEnabled: false
# 验证码类型 math 数字计算 char 字符验证 # 验证码类型 math 数字计算 char 字符验证
captchaType: math captchaType: math
#服务器外网访问地址
serverUrl: http://ndkh.tstc.edu.cn
# 开发环境配置 # 开发环境配置
server: server:

Loading…
Cancel
Save