CQG
2023-02-17 dce91a03ef54f29a79f557ecbe0251cd607be158
ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/service/FastDfsSysFileServiceImpl.java
@@ -1,16 +1,18 @@
package com.ruoyi.file.service;
import org.apache.commons.io.FilenameUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
import com.github.tobato.fastdfs.service.FastFileStorageClient;
import com.ruoyi.common.core.utils.file.FileTypeUtils;
import java.io.InputStream;
/**
 * FastDFS文件存储
 *
 * FastDFS 文件存储
 *
 * @author ruoyi
 */
@Service
@@ -27,17 +29,18 @@
    /**
     * FastDfs文件上传接口
     *
     *
     * @param file 上传的文件
     * @param baseDir 相对应用的基目录
     * @return 访问地址
     * @throws Exception
     */
    @Override
    public String uploadFile(MultipartFile file, String baseDir) throws Exception
    public String uploadFile(MultipartFile file) throws Exception
    {
        StorePath storePath = storageClient.uploadFile(file.getInputStream(), file.getSize(),
                FilenameUtils.getExtension(file.getOriginalFilename()), null);
        InputStream inputStream = file.getInputStream();
        StorePath storePath = storageClient.uploadFile(inputStream, file.getSize(),
                FileTypeUtils.getExtension(file), null);
        inputStream.close();
        return domain + "/" + storePath.getFullPath();
    }
}