Fdfs anti-theft chain Configuration and Java development

Source: Internet
Author: User

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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.