1. requests通过Post/Form上传文件
以微信上传logo接口为例:
url
https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token=ACCESS_TOKEN
参数
buffer | 文件数数据流 |
access_token | 调用凭证 |
curl -F buffer=@test.jpg "http://file.api.wechat.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE"
upload_url = upload_logo_format % token
files = {'buffer': open(logo_path, 'rb')}
resp = requests.post(upload_url, files=files)
refer Upload Image using POST form data in Python-requests