In the last article technically: http://blog.csdn.net/www_wangzheguilai/article/details/76647443
1, modify the configuration file
Configure the anti-theft chain function, in fact, the configuration end is quite simple, as follows:
Cd/etc/fdfs
Vim http.conf
#true-Open anti-theft chain check, false-close the anti-theft chain
Http.anti_steal.check_token=true
#防盗链密钥
http.anti_steal.secret_key=fastdfs1234567890
#每次生成的访问链的有效时间, Unit s
http.anti_steal.token_ttl=900
#校验失败, access to the picture
Http.anti_steal.token_check_fail=/etc/fdfs/account_order.png
2, Java end
Modifying Java-side fdfs_client.conf files
Http.anti_steal_token = True
Http.secret_key = FastDFS1234567890
tracker_server = 10.80.103.63:22122
The Java code block that generates the connection to the burglar link is as follows:
String[] results = new STRING[2];
int errno = storageclient1.split_file_id (Fileid, results);
if (errno!= 0) {
throw new myexception ("Fileid format Error!")
int ts = (int) (System.currenttimemillis ()/1000);
String token = Protocommon.gettoken (results[1], TS, Clientglobal.getg_secret_key ());
return serveraddr + "/" + Fileid + "? token=" + token + "&ts=" + ts;
Generate Anti-Theft chain Address:
http://10.80.103.63:9999/group1/M00/00/00/ClBnP1mD8NqAe-VeAABdrZgsqUU923_big.jpg?token= bcf7ed89b01ee6d72010d70eda63e0e8&ts=1501821311