我在通过 Flickr API 上传图片时遇到问题。
我使用 OAuthLib 请求 ( https://github.com/requests/requests-oauthlib )
Flickr 文档:https://secure.flickr.com/services/api/upload.api.html
我的代码:
params = {
'format' : 'json',
"nojsoncallback" : "1",
'api_key' : 'my_api_key',
}
with open('myfile.jpg', 'rb') as f:
files = {'file': f}
r = the_oauth_requests_session.post('https://up.flickr.com/services/upload/', params=params, files=files)
print r.content
但是在内容中我发现这个错误:'No photo specified'。
上传照片的方式是什么?
我已通过身份验证,其他 api 调用工作正常(例如“flickr.photosets.create”)
提前致谢
最佳答案
我认为 Flickr 不允许您上传图片和视频以外的任何其他文件类型。 在您的代码中:
files = {'file': f}
您确定"file"的类型正确吗?
关于python - Flickr API : Upload an image with python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25208309/