1
张贴在usergrid文件我能够发布文件,curl
无法使用请求
curl -X POST -i -F name='memo.txt' -F [email protected]/home/tester/Desktop/memo.txt
'http://localhost:8080/***/***/concerts/008?
access_token=YWMtraI2DF21EeWx_Rm4tdnmrwAAAVACjcyGG8TpdXJBXdjnRJ2SeqIAZI1T8Xk'
但是,当我试图用requests.post
同样的事情,文件没有上传到服务器。有人知道为什么会发生这种情况。
import requests
url = 'http://localhost:8080/***/***/concerts/008'
files = {
'memo.txt': open('/home/tester/Desktop/memo.txt', 'rb'),
'name': 'memo.txt'
}
r = requests.post(
url, files=files,
params=dict(access_token='YWMtraI2DF21EeWx_Rm4tdnmrwAAAVACjcyGG8TpdXJBXdjnRJ2SeqIAZI1T8Xk')
)
我包括'files'字典的名字,但仍然是文件不上传...我可以上传文件,上面提到的curl请求.. – Lionel
@Pattinson:啊,我的错误,我错过了你命名的字段'memo.txt';该字段在curl请求中被命名为'file'。 –
谢谢...我很想念它 – Lionel