1、fastdfs服务器
链接:https://pan.baidu.com/s/1oMIkX87zEZbq8EUZZXs3xA
提取码:9999
2、创建一个普通的maven工程,加入依赖:
<dependency>
<groupId>org.csource</groupId>
<artifactId>fastdfs-client-java</artifactId>
<version>1.27-SNAPSHOT</version>
</dependency>
3、resources文件下创建fdfs_client.conf,内容如下:
tracker_server=192.168.25.133:22122
4、入门小程序,Demo1:
public class Demo1 {
public static void main(String[] args) throws IOException, MyException {
ClientGlobal.init("F:\\javastudy\\fastdfstest\\src\\main\\resources\\fdfs_client.conf");
TrackerClient trackerClient = new TrackerClient();
TrackerServer trackerServer = trackerClient.getConnection();
StorageServer storageServer = null;
StorageClient storageClient = new StorageClient(trackerServer, storageServer);
String[] pngs = storageClient.upload_file("E:\\a.png", "png", null);
for (String png : pngs) {
System.out.println(png);
}
}
}
5、程序执行结果:
6、访问 http://192.168.25.133/group1/M00/00/00/wKgZhV9oiPCAA3zIAABUcP96vQc924.png