是前端用户type=file那样上传图片文件。
我执行ret, info = put_file(token, key, localfile)
老是说localfile没有这个文件,但换成路径的时候,就能上传。谢谢了
PHP中文网2017-04-18 09:21:01
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.