SpringBoot整合FastDFS

Bertha 。 2023-02-09 13:13 57阅读 0赞
  • pom


    com.github.tobato
    fastdfs-client
    1.26.7
  • application.yml

    fdfs:
    connect-timeout: 30 # 连接的超时时间
    so-timeout: 30 # 读取的超时时间
    tracker-list: 192.168.1.155:22122 # tracker服务所在的ip地址和端口号

  • service

    @Service
    public class FdfsServiceImpl implements FdfsService {

    1. @Autowired
    2. private FastFileStorageClient fastFileStorageClient;
    3. @Override
    4. public String upload(MultipartFile file, String fileExtName) throws Exception {
    5. StorePath storePath = fastFileStorageClient.uploadFile(file.getInputStream(),
    6. file.getSize(),
    7. fileExtName,
    8. null);
    9. String path = storePath.getFullPath();
    10. return path;
    11. }

    }

这样就可以拿到上传后的文件路径了

发表评论

表情:
评论列表 (有 0 条评论,57人围观)

还没有评论,来说两句吧...

相关阅读

    相关 springboot整合fastdfs

    在项目开发中经常会碰到做文件上传的功能,一般来说,文件上传的步骤就那么几步,前台通过提交一个选中的文件,后端对文件做处理然后将文件上传至指定的地址,这个地址是一个真实的物理存储