Springboot整合FastDfs实现图片上传
(1) 前提条件:
1.完成对Fastdfs环境的搭建;若没有,请查看FastDfs搭建教程。
2.在pom.xml文件中,添加fastdfs引用依赖包。
<dependency>
<groupId>org.csource</groupId>
<artifactId>fastdfs-client-java</artifactId>
<version>1.27-SNAPSHOT</version>
</dependency>
若提示错误:Dependency 'org.csource:fastdfs-client-java:1.27-SNAPSHOT' not founnd.请看博客:解决Fastdfs依赖包问题。
(2)进入正题:
1.在resource目录下新建文件client.conf,并添加Fastdfs相关配置
2.添加Fastdfs工具类,FastDFSClientUtil.java
package com.discount.common.util;
import org.csource.common.NameValuePair;
import org.csource.fastdfs.ClientGlobal;
import org.csource.fastdfs.StorageClient1;
import org.csource.fastdfs.StorageServer;
import org.csource.fastdfs.TrackerClient;
import org.csource.fastdfs.TrackerServer;
public class FastDFSClient