qiniu / python-sdk

Qiniu Resource (Cloud) Storage SDK for Python
MIT License
546 stars 258 forks source link

download_private_link无法返回可用链接 #184

Closed hellflame closed 8 years ago

hellflame commented 8 years ago

按照文档里面的方法

from hashlib import sha1
url = 'http://developer.qiniu.com/resource/flower.jpg?e=1451491200'
secret = 'MY_SECRET_KEY'
print urlsafe_b64encode(hmac.new(url,secret , sha1).digest())
   _wtPUG_vrv3OO3LRNj7W7lju2kM=

并不能得到文档所示的url诶 或者说我的加密方式有错么

hellflame commented 8 years ago

已经

from base64 import urlsafe_b64encode
import hmac

忘了写

longbai commented 8 years ago

汗,你这个是算hmac的 base64 编码,直接用auth里的函数就好

hellflame commented 8 years ago

然而在官方文档里面不就是hmac的base64么2333333,真的是我理解错误么............=.= 然而对于pythonsdk里面给的auth里的函数.....私有空间貌似只能用默认域名......并不能用自己设置的域名(自定义域名返回的链接表示404).....这是因为只为默认域名解析的缘故么.......

forrest-mao commented 8 years ago

@hellflame 可以用自定义域名的私有链接,使用 auth的 private_download_url,第二个参数的url中的path部分要保证是空间中已经存在的key

hellflame commented 8 years ago

@forrest-mao 我已经这么做了......之前只是觉得还要用那么长的默认域名比较麻烦........