import java.io.IOException;
import java.net.InetSocketAddress;
import org.csource.common.MyException;
import org.csource.fastdfs.ClientGlobal;
import org.csource.fastdfs.StorageClient1;
import org.csource.fastdfs.TrackerClient;
import org.csource.fastdfs.TrackerGroup;
import org.csource.fastdfs.TrackerServer;
public class MainTest {
public static void main(String[] args) throws IOException, MyException {
//初始化配置文件
ClientGlobal.init(MainTest.class.getResource("/").getPath()+"fastdfs.properties");
//获取tracker的客户端对象
//
TrackerGroup group = new TrackerGroup(new InetSocketAddress[]{new InetSocketAddress("追踪器1的IP1地址", 22122),new InetSocketAddress("追踪器2的IP2地址", 22122)});
TrackerClient tClient = new TrackerClient(group);
TrackerServer tServer = tClient.getConnection();
StorageClient1 sClient = new StorageClient1(tServer, null);
String str = sClient.upload_file1("", "jsp",null);
System.out.println(str);
tServer.close();
}
}
java端调用fastdfs存储文件方法测试之(有两个追踪器时的调用)
最新推荐文章于 2022-10-18 19:25:10 发布