FastDFS文件操作工具类
先安装好图片服务器,然后在项目中配置好图片服务器的配置
@Component
public class FastDFSUtil {
private static ThumbImageConfig thumbImageConfig;
private static FastFileStorageClient fastFileStorageClient;
private static FdfsWebServer fdfsWebServer;
public FastDFSUtil(ThumbImageConfig thumbImageConfig, FastFileStorageClient fastFileStorageClient, FdfsWebServer fdfsWebServer) {
FastDFSUtil.thumbImageConfig = thumbImageConfig;
FastDFSUtil.fastFileStorageClient = fastFileStorageClient;
FastDFSUtil.fdfsWebServer = fdfsWebServer;
}
/**
* @param multipartFile 文件对象
* @return 返回文件地址
* @author qbanxiaoli
* @description 上传文件
*/
@SneakyThrows
public static String uploadFile(MultipartFile multipartFile) {
StorePath storePath = fastFileStorageClient.uploadFile(multipartFile.getInputStream(), multipartFile.getSize(), FilenameUtils.getExtension(mul