SpringBoot整合FastDFS
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 {@Autowired
private FastFileStorageClient fastFileStorageClient;
@Override
public String upload(MultipartFile file, String fileExtName) throws Exception {
StorePath storePath = fastFileStorageClient.uploadFile(file.getInputStream(),
file.getSize(),
fileExtName,
null);
String path = storePath.getFullPath();
return path;
}
}
这样就可以拿到上传后的文件路径了
还没有评论,来说两句吧...