分布式文件问题以及修改意见
This commit is contained in:
parent
08436a878a
commit
9551520ee3
|
|
@ -3,6 +3,7 @@ package com.hchyun.web.controller.common;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.hchyun.system.utils.FtpUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -42,7 +43,7 @@ public class CommonController {
|
|||
// if (!FileUtils.isValidFilename(fileName)) {
|
||||
// throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 " , fileName));
|
||||
// }
|
||||
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
|
||||
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("."));
|
||||
String filePath = HchYunConfig.getDownloadPath() + fileName;
|
||||
|
||||
response.setCharacterEncoding("utf-8");
|
||||
|
|
@ -68,11 +69,11 @@ public class CommonController {
|
|||
String filePath = HchYunConfig.getUploadPath();
|
||||
// 上传并返回新文件名称
|
||||
String fileName = FileUploadUtils.upload(filePath, file);
|
||||
String url = serverConfig.getUrl() + fileName;
|
||||
String url = FtpUtils.getApiurl() + fileName;
|
||||
// String url = serverConfig.getUrl() + fileName;
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("fileName", fileName);
|
||||
ajax.put("url", url);
|
||||
ajax.put("addres", "/test");
|
||||
return ajax;
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
|
|
|
|||
|
|
@ -6,9 +6,13 @@ spring:
|
|||
druid:
|
||||
# 主库数据源
|
||||
master:
|
||||
url: jdbc:mysql://114.215.82.135:3306/hcybase?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: hcybase
|
||||
password: hcybase@2020
|
||||
# url: jdbc:mysql://114.215.82.135:3306/hcybase?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
# username: hcybase
|
||||
# password: hcybase@2020
|
||||
url: jdbc:mysql://13.75.92.40:3306/gen?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
# url: jdbc:mysql://10.0.0.4:3306/gen?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: gen
|
||||
password: zcsbKxPseM8LhFdT
|
||||
# 从库数据源
|
||||
slave:
|
||||
# 从数据源开关/默认关闭
|
||||
|
|
|
|||
|
|
@ -9,24 +9,30 @@ hchyun:
|
|||
# 实例演示开关
|
||||
demoEnabled: true
|
||||
# 文件路径 示例( Windows配置D:/hchyun/uploadPath,Linux配置(宝塔) /www/wwwroot/hchyun/uploadPath)
|
||||
profile: F:/hchyun/uploadPath
|
||||
# profile: /www/wwwroot/gen/uploadPath
|
||||
profile: D:/gen/uploadPath
|
||||
# 获取ip地址开关
|
||||
addressEnabled: false
|
||||
addressEnabled: true
|
||||
# 验证码类型 math 数组计算 char 字符验证
|
||||
captchaType: math
|
||||
ftp:
|
||||
# ftp服务器ip地址
|
||||
ftpAddress: 114.215.82.135
|
||||
# ftpAddress: 114.215.82.135
|
||||
ftpAddress: 13.75.92.40
|
||||
# 端口号
|
||||
ftpPort: 21
|
||||
# 用户名
|
||||
ftpUsername: hcyftp
|
||||
# ftpUsername: hcyftp
|
||||
ftpUsername: genfile
|
||||
# 密码
|
||||
ftpPassword: hcyftp@2020
|
||||
# ftpPassword: hcyftp@2020
|
||||
ftpPassword: xanTPWM7jC4XpcWx
|
||||
# 字符集编码
|
||||
encoding: UTF-8
|
||||
# 资源域名末尾以/结尾
|
||||
resources: http://download.hchyun.com
|
||||
resources: https://download.odliken.top
|
||||
#后端部署域名
|
||||
apiurl: https://apig.odliken.top
|
||||
# 公开目录
|
||||
pubfiles: pubfiles
|
||||
# 保护目录
|
||||
|
|
@ -80,11 +86,13 @@ spring:
|
|||
# redis 配置
|
||||
redis:
|
||||
# 地址
|
||||
host: 114.215.82.135
|
||||
# host: 114.215.82.135
|
||||
# host: 127.0.0.1
|
||||
host: 13.70.28.14
|
||||
# 端口,默认为6379
|
||||
port: 6378
|
||||
port: 6379
|
||||
# 密码
|
||||
password: hcy@2020
|
||||
password: 926425
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
lettuce:
|
||||
|
|
|
|||
|
|
@ -56,8 +56,18 @@ public class FtpUtils {
|
|||
private static String encoding;
|
||||
//静态资源域名
|
||||
private static String resources;
|
||||
//后端部署域名
|
||||
private static String apiurl;
|
||||
|
||||
|
||||
public static String getApiurl() {
|
||||
return apiurl;
|
||||
}
|
||||
|
||||
public void setApiurl(String apiurl) {
|
||||
FtpUtils.apiurl = apiurl;
|
||||
}
|
||||
|
||||
public static String getAvatarDir() {
|
||||
return pubfiles + "avatar";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
文件上传:
|
||||
文件通过上传接口上传到后端 后端通过ftp存放到公共临时文件存放中心,返回临时文件中的静态资源路径
|
||||
点击提交时:后端通过ftp从临时文件资源中心获取到文件,在通过ftp上传到文件资源中心并删除临时文件中心中的文件
|
||||
下载:
|
||||
点击下载,系统通过ftp从文件资源中心获取到文件流,通过ftp存放在临时文件中,并返回当前文件在临时文件中心的网络静态资源路径,前端再一次发送请求到,
|
||||
1.后端通过网络资源获取到网络文件并返回给前端
|
||||
2.通过js直接获取网络资源
|
||||
最后都需要连接零时资源中心的ftp删除文件
|
||||
Loading…
Reference in New Issue