linux上部署FastDFS网上有很多 这里就不说了。
链接地址:http://oldcat1981.blog.51cto.com/10670523/1766810
http://blog.csdn.net/adminjesseli/article/details/52640775
http://blog.csdn.net/u013378306/article/details/74850231
不懂的地方 对照着看就知道为什么了。
=========================================java 上面访问 文件服务器==========================================
fdfs_client.conf
network_timeout = 30
#对这些设置还不是很清楚
charset = ISO8859-1
http.tracker_http_port = 8080
http.anti_steal_token = no
http.secret_key = FastDFS1234567890
#tracker_server的设置是必须的
tracker_server = 192.168.0.111:22122
public class fdfsTest {
public static void main(String[] args) throws IOException, MyException {
ClientGlobal.initByProperties("config/fastdfs-client.properties");
//创建一个tracker客户端对象
TrackerClient trackerClient = new TrackerClient();
//使用trackerclient连接trackersever对象
TrackerServer trackerServer = trackerClient.getConnection();
//创建一个straged server对象
StorageServer storageServer = null;
//创建一个storage client 对象
StorageClient1 storageClient = new StorageClient1(trackerServer, storageServer);
//利用storageclient对象上传图片
//参数一为文件所在的路径(不要有中文)
//参数二为文件的拓展名
//参数三为文件扩展信息
String[] upload_file = storageClient.upload_file("C:/Users/Administrator/Desktop/20160802130136931.jpg", "jpg", null);
//upload_file 存储着访问路径
for(String s : upload_file){
System.out.println(s);
}
}
}
返回的路径:
group1
M00/00/00/CmkgN1meia-APHL-AAF4n3s-n5w069.jpg
从文件服务器上获取图片就是:
http:// ip: 端口/group1/M00/00/00/CmkgN1meia-APHL-AAF4n3s-n5w069.jpg
需要用的jar都可以从 https://github.com/happyfish100https://github.com/happyfish100 上下载
注:所需要的: