前面文件系统平台搭建好了,现在就要写客户端代码在系统中实现上传下载,这里只是简单的测试代码。
1、首先需要搭建 FastDFS 客户端Java开发环境
① 项目中使用maven进行依赖管理,可以在pom.xml中引入如下依赖即可:
<dependency> <groupId>net.oschina.zcx7878</groupId> <artifactId>fastdfs-client-java</artifactId> <version>1.27.0.0</version> </dependency>
其它的方式,参考官方文档:https://github.com/happyfish100/fastdfs-client-java
② 引入配置文件
可直接复制包下的 fastdfs-client.properties.sample 或者 fdfs_client.conf.sample,到你的项目中,去掉.sample。
我这里直接复制 fastdfs-client.properties.sample 中的配置到项目配置文件 config.properties 中,修改tracker_servers。只需要加载这个配置文件即可
2、客户端API
个人封装的FastDFS Java API以同步到github:https://github.com/bojiangzhou/lyyzoo-fastdfs-java.git
转载地址: https://www.cnblogs.com/chiangchou/p/fastdfs.html#_label4_2