标签:ini str private ber pre height creat fas common
一、配置文件(fdfs_client.properties)
1
2
3
4
5
6
7
8
9
10
|
connect_timeout = 30 network_timeout = 60 charset = ISO8859-1 # nginx 存储器端口 http.tracker_http_port = 8888 http.anti_steal_token = no http.secret_key = 123456 # 追踪器服务端口 tracker_server = 192.168.146.131:22122 |
二、Java上传跟图片
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
package org.soa.test.fastdfs; import org.csource.common.MyException; import org.csource.fastdfs.*; import java.io.IOException; /** * Created by JamesC on 16-10-25. */ public class FastDfsTest { public static void main(String[] args) { uploadfile(); } private static void uploadfile() { // 1、把FastDFS提供的jar包添加到工程中 // 2、初始化全局配置。加载一个配置文件。 try { ClientGlobal.init( "D:\\fdfs_client.properties" ); // 3、创建一个TrackerClient对象。 TrackerClient trackerClient = new TrackerClient(); // 4、创建一个TrackerServer对象。 TrackerServer trackerServer = null ; trackerServer = trackerClient.getConnection(); // 5、声明一个StorageServer对象,null。 StorageServer storageServer = null ; // 6、获得StorageClient对象。 StorageClient storageClient = new StorageClient(trackerServer, storageServer); // 7、直接调用StorageClient对象方法上传文件即可。 String[] strings = storageClient.upload_file( "D:\\coupon.jpg" , "jpg" , null ); for (String string : strings) { System.out.println(string); } } catch (Exception e) { e.printStackTrace(); } } } |
四、Java API客户端jar包可从群里下载
标签:ini str private ber pre height creat fas common
原文地址:http://www.cnblogs.com/gossip/p/5996202.html