Pre Merge pull request !70 from Mood/N/A

This commit is contained in:
Mood 2022-07-30 05:57:56 +00:00 committed by Gitee
commit 5d7fbc94f4
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 43 additions and 42 deletions

View File

@ -1,42 +1,43 @@
package com.ruoyi.file.service; package com.ruoyi.file.service;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.springframework.beans.factory.annotation.Autowired; import com.ruoyi.file.utils.FileUploadUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.multipart.MultipartFile; import org.springframework.stereotype.Service;
import com.github.tobato.fastdfs.domain.fdfs.StorePath; import org.springframework.web.multipart.MultipartFile;
import com.github.tobato.fastdfs.service.FastFileStorageClient; import com.github.tobato.fastdfs.domain.fdfs.StorePath;
import com.github.tobato.fastdfs.service.FastFileStorageClient;
/**
* FastDFS 文件存储 /**
* * FastDFS 文件存储
* @author ruoyi *
*/ * @author ruoyi
@Service */
public class FastDfsSysFileServiceImpl implements ISysFileService @Service
{ public class FastDfsSysFileServiceImpl implements ISysFileService
/** {
* 域名或本机访问地址 /**
*/ * 域名或本机访问地址
@Value("${fdfs.domain}") */
public String domain; @Value("${fdfs.domain}")
public String domain;
@Autowired
private FastFileStorageClient storageClient; @Autowired
private FastFileStorageClient storageClient;
/**
* FastDfs文件上传接口 /**
* * FastDfs文件上传接口
* @param file 上传的文件 *
* @return 访问地址 * @param file 上传的文件
* @throws Exception * @return 访问地址
*/ * @throws Exception
@Override */
public String uploadFile(MultipartFile file) throws Exception @Override
{ public String uploadFile(MultipartFile file) throws Exception
StorePath storePath = storageClient.uploadFile(file.getInputStream(), file.getSize(), {
FilenameUtils.getExtension(file.getOriginalFilename()), null); StorePath storePath = storageClient.uploadFile(file.getInputStream(), file.getSize(),
return domain + "/" + storePath.getFullPath(); FileUploadUtils.getExtension(file), null);
} return domain + "/" + storePath.getFullPath();
} }
}