fastdfs fix upload bug、升级小版本

pull/84/head
duandazhi 4 years ago
parent 938fc7d088
commit 407b7e526f

@ -25,7 +25,7 @@
<spring-boot.mybatis>2.1.4</spring-boot.mybatis> <spring-boot.mybatis>2.1.4</spring-boot.mybatis>
<swagger.fox.version>3.0.0</swagger.fox.version> <swagger.fox.version>3.0.0</swagger.fox.version>
<swagger.core.version>1.6.2</swagger.core.version> <swagger.core.version>1.6.2</swagger.core.version>
<tobato.version>1.26.5</tobato.version> <tobato.version>1.26.7</tobato.version>
<kaptcha.version>2.3.2</kaptcha.version> <kaptcha.version>2.3.2</kaptcha.version>
<pagehelper.boot.version>1.3.1</pagehelper.boot.version> <pagehelper.boot.version>1.3.1</pagehelper.boot.version>
<druid.version>1.2.6</druid.version> <druid.version>1.2.6</druid.version>

@ -12,6 +12,8 @@ import org.springframework.context.annotation.Configuration;
* @author dazer * @author dazer
* @see FastDfsServiceImpl * @see FastDfsServiceImpl
* FastDFS {@link PooledConnectionFactory} * FastDFS {@link PooledConnectionFactory}
*
* 使: DockerFastDFS https://www.cnblogs.com/cao-lei/p/13470695.html
*/ */
@RefreshScope @RefreshScope
@Configuration @Configuration

@ -1,5 +1,6 @@
package com.ruoyi.file.service; package com.ruoyi.file.service;
import com.github.tobato.fastdfs.domain.fdfs.MetaData;
import com.github.tobato.fastdfs.exception.FdfsUnsupportStorePathException; import com.github.tobato.fastdfs.exception.FdfsUnsupportStorePathException;
import com.ruoyi.common.core.exception.CustomException; import com.ruoyi.common.core.exception.CustomException;
import com.ruoyi.file.config.FastDfsConfig; import com.ruoyi.file.config.FastDfsConfig;
@ -8,11 +9,15 @@ import org.apache.commons.lang3.StringUtils;
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.context.annotation.Primary;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import com.github.tobato.fastdfs.domain.fdfs.StorePath; import com.github.tobato.fastdfs.domain.fdfs.StorePath;
import com.github.tobato.fastdfs.service.FastFileStorageClient; import com.github.tobato.fastdfs.service.FastFileStorageClient;
import java.util.HashSet;
import java.util.Set;
/** /**
* FastDFS * FastDFS
* @author ruoyi * @author ruoyi
@ -38,7 +43,7 @@ public class FastDfsServiceImpl implements IDfsService
@Override @Override
public String uploadFile(MultipartFile file) throws Exception public String uploadFile(MultipartFile file) throws Exception
{ {
return this.uploadFile(file); return this.uploadFile(file, null);
} }
@Override @Override
@ -46,8 +51,11 @@ public class FastDfsServiceImpl implements IDfsService
// fastdsf 这里的 modules 没用 // fastdsf 这里的 modules 没用
validateModule(file, modules); validateModule(file, modules);
Set<MetaData> metaDataSet = new HashSet<>(1);
metaDataSet.add(new MetaData("groupName", "group1"));
StorePath storePath = storageClient.uploadFile(file.getInputStream(), file.getSize(), StorePath storePath = storageClient.uploadFile(file.getInputStream(), file.getSize(),
FilenameUtils.getExtension(file.getOriginalFilename()), null); FilenameUtils.getExtension(file.getOriginalFilename()), metaDataSet);
/// fileUrl = "http://127.0.0.1:22122/" + storePath.getFullPath(); /// fileUrl = "http://127.0.0.1:22122/" + storePath.getFullPath();
return fastDfsConfig.getDomain() + "/" + storePath.getFullPath(); return fastDfsConfig.getDomain() + "/" + storePath.getFullPath();

@ -17,11 +17,9 @@ spring:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
namespace: 72b686a1-d9f6-499f-8275-e481b664779e
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
namespace: 72b686a1-d9f6-499f-8275-e481b664779e
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置
@ -37,7 +35,7 @@ file:
# 文件服务器之2 ftp # 文件服务器之2 ftp
ftp: ftp:
host-name: 118.31.2.53 endpoint: 118.31.2.53
port: 21 port: 21
user-name: lanjinjun user-name: lanjinjun
password: password:
@ -57,14 +55,16 @@ minio:
secretKey: QyVqGnhIQQE734UYSUFlGOZViE6+ZlDEfUG3NjhJ secretKey: QyVqGnhIQQE734UYSUFlGOZViE6+ZlDEfUG3NjhJ
bucketName: appt-file bucketName: appt-file
domain: https://yq666.bj.gov.cn domain: https://yq666.bj.gov.cn
expiry-duration: 32400
# 文件服务器之5 aliyun oss # 文件服务器之5 aliyun oss
aliyun-oss: aliyun-oss:
access-key-id: LTAI4GDQSbwgmbsRxxbDXnKT access-key: LTAI4GDQSbwgmbsRxxbDXnKT
access-key-secret: I1xYosCsIf4YgHeFbWUOU4faImeWD2 secret-key: I1xYosCsIf4YgHeFbWUOU4faImeWD2
bucket-name: react-yuebaoxiao-pro bucket-name: react-yuebaoxiao-pro
endpoint: oss-cn-shanghai.aliyuncs.com endpoint: oss-cn-shanghai.aliyuncs.com
domain: https://react-yuebaoxiao-pro.oss-cn-shanghai.aliyuncs.com domain: https://react-yuebaoxiao-pro.oss-cn-shanghai.aliyuncs.com
expiry-duration: 32400
# 文件服务器之6 qiniu 七牛 kodo # 文件服务器之6 qiniu 七牛 kodo
qiniu: qiniu:
@ -72,3 +72,4 @@ qiniu:
secret-key: CwTEh1kSLBdxBhIWfFz6h1GgDSokx97CYEV0cC1O secret-key: CwTEh1kSLBdxBhIWfFz6h1GgDSokx97CYEV0cC1O
bucket-name: guangdong-oss bucket-name: guangdong-oss
domain: http://guangdong-oss.ityun.ltd domain: http://guangdong-oss.ityun.ltd
expiry-duration: 32400

Loading…
Cancel
Save