1. []
    2. :https://github.com/happyfish100/fastdfs-client-java
    3. :https://github.com/bojiangzhou/lyyzoo-fastdfs-java
    1. <dependency>
    2. <groupId>net.oschina.zcx7878</groupId>
    3. <artifactId>fastdfs-client-java</artifactId>
    4. <version>1.27.0.0</version>
    5. </dependency>
    6. [配置]
    7. :直接复制包下的 fastdfs-client.properties.sample 或者 fdfs_client.conf.sample 到项目
    8. :配置 tracker_servers

    FastDFS - JAVA客户端访问 - 图1

    1. []
    2. // FastDFS的权限控制是在服务端开启token验证, 客户端根据文件名、当前unix时间戳、秘钥获取token
    3. // 在地址中带上token参数即可通过http方式访问文件
    4. [服务端开启token验证]
    5. vim /etc/fdfs/http.conf
    6. 设置为true表示开启token验证
    7. http.anti_steal.check_token=true
    8. 设置token失效的时间单位为秒(s)
    9. http.anti_steal.token_ttl=1800
    10. 密钥,跟客户端配置文件的fastdfs.http_secret_key保持一致
    11. http.anti_steal.secret_key=FASTDFS1234567890
    12. 如果token检查失败,返回的页面
    13. http.anti_steal.token_check_fail=/ljzsg/fastdfs/page/403.html
    14. [配置客户端]
    15. # token 防盗链功能
    16. fastdfs.http_anti_steal_token=true
    17. # 密钥
    18. fastdfs.http_secret_key=FASTDFS1234567890
    19. [客户端生成token]
    20. // 访问文件需要带上生成的token以及unix时间戳,所以返回的token是token和时间戳的拼接
    21. file.ljzsg.com/group1/M00/00/00/wKgzgFnkaXqAIfXyAAEoRmXZPp878.jpeg?token=078d370098b03e9020b82c829c205e1f&ts=1508141521