python - 访问七牛下载链接出现{"error":"download token auth failed"}
PHP中文网
PHP中文网 2017-04-17 13:49:00
0
4
933

根据下载私有文件的指南生成私有文件链接,发现文件名是中文的话生成的private_url用chrome会出现

{"error":"download token auth failed"}

的响应(对比英文文件名是正常的)。

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(4)
阿神

Qiniu requires that all links and file names must be UTF-8 encoded, so take a look at your code.

Key must be encoded in utf-8, and an error will be reported when accessing using non-utf-8 encoded resource names.

http://developer.qiniu.com/docs/v6/api/reference/security/download-token.html

When you download the Chinese key certificate, the key needs to be URL escaped. Please refer to the instructions at the end of the above document.

Ty80

You are lucky, I have met you, let me tell you

Chrome, especially on mac systems (it may have nothing to do with the system or the type of browser, that’s how some computers are anyway)

You are using UTF-8 encoded URL. After clicking the link, the browser will convert it again. Sometimes it will be converted to all uppercase, and sometimes it will be all lowercase.

For example, original url=xxx.com/downfile/fileidHHHHHaaaaa.rar?e=&token=******
It will be automatically transcoded into url=xxx.com/downfile/fileidHHHHHAAAAA.rar?e=&token=********

Note that lower case aaaaa has been changed to upper case AAAAA, or it may be that the original upper case has been changed to lower case

This is just an example, the actual situation is to transcode the Chinese part after UTF-8 encoding

Automatic transcoding may not be accurate, but no matter what <a href="***aaa" aaa is written in the HTML, if you click to open it, you will find that the address opened by the browser becomes AAA

Because this problem has been discovered for a long time, I don’t remember it very clearly. Anyway, it is basically like this. Make sure that your file name does not include Chinese characters, and this problem will not occur

Ty80

In addition to the answer above, there are other possibilities. The reason why I clicked on this post is because I encountered the same problem as the original poster, but I checked my file and there was no Chinese. Instead, there was a space. , after I removed the spaces, it was fine. I leave a message here to prevent future generations from getting into the trap

PHPzhong

I don’t have Chinese, why do I get this kind of question even if there are no spaces

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!