python - django上传图片文件到七牛
伊谢尔伦
伊谢尔伦 2017-04-18 09:19:01
0
2
821

是前端用户type=file那样上传图片文件。
我执行ret, info = put_file(token, key, localfile)
老是说localfile没有这个文件,但换成路径的时候,就能上传。谢谢了

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(2)
洪涛
key = 'my-python-logo.png';

#上传文件到七牛后, 七牛将文件名和文件大小回调给业务服务器。
policy={
 'callbackUrl':'http://your.domain.com/callback.php',
 'callbackBody':'filename=$(fname)&filesize=$(fsize)'
 }

token = q.upload_token(bucket_name, key, 3600, policy)

localfile = './sync/bbb.jpg'

ret, info = put_file(token, key, localfile)
print(info)
assert ret['key'] == key
assert ret['hash'] == etag(localfile)

I don’t quite understand what you are talking about. Can you give me the values ​​​​of key and localfile?
First of all, make sure you have not passed the key and localfile backwards.

小葫芦

You can try django-qiniu-storage

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!