pom.xml

<dependency>
    <groupId>com.github.tobato</groupId>
    <artifactId>fastdfs-client</artifactId>
    <version>1.26.7</version>
</dependency>

 

application.yml

############################################################
#
# fdfs 配置
#
############################################################
fdfs:
  connect-timeout: 30  #连接超时时间
  so-timeout: 30   #读取超时时间
  tracker-list: 10.0.0.210:22122  #tracker服务所在的ip地址

 

Service

@Service
public class FdfsServiceImpl implements FdfsService {

    @Autowired
    private FastFileStorageClient fastFileStorageClient;

    @Override    //文件,后缀名
    public String upload(MultipartFile multipartFile,String fileExtName) throws Exception {
        StorePath storePath = fastFileStorageClient.uploadFile(multipartFile.getInputStream(), multipartFile.getSize(),fileExtName,null);
        String path = storePath.getFullPath();
        return path;   //返回文件路径
    }
}

 

 

 

 

最后修改于 2020-04-21 10:04:17
如果觉得我的文章对你有用,请随意赞赏
扫一扫支付
上一篇