【问题标题】:Flickr API: Upload an image with pythonFlickr API:使用 python 上传图像
【发布时间】:2014-10-02 05:13:04
【问题描述】:

我无法通过 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

但是在内容中我可以找到这个错误:“没有指定照片”。

上传照片的方法是什么?

我已通过身份验证,其他 api 调用工作正常(如“flickr.photosets.create”)

提前谢谢你

【问题讨论】:

标签: python oauth python-requests flickr


【解决方案1】:

我认为 Flickr 不允许您上传除图像和视频之外的任何其他文件类型。 在您的代码中:

files = {'file': f}

您确定“文件”的类型正确吗?

【讨论】:

    【解决方案2】:

    解决方法很简单:

    files = {'photo': f}
    

    代替:

    files = {'file': f}
    

    【讨论】:

      猜你喜欢
      • 2021-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-27
      • 1970-01-01
      相关资源
      最近更新 更多