Python,发出POST请求从S3位置传递文件

时间:2017-10-19 10:05:26

标签: python rest amazon-s3 http-post

我正在尝试实现一个简单的场景,我从S3存储桶读取二进制文件,并通过POST数据发送到RESTFUL服务。

在另一篇文章中,我发现文档要进行复杂的POST: http://docs.python-requests.org/en/latest/user/quickstart/#more-complicated-post-requests

>>> url = 'http://httpbin.org/post'
>>> files = {'file': ('report.xls', open('report.xls', 'rb'), 'application/vnd.ms-excel', {'Expires': '0'})}

>>> r = requests.post(url, files=files)
>>> r.text
{
  ...
  "files": {
    "file": "<censored...binary...data>"
  },
  ...
}

我不知道是否以及如何将我的S3文件传递给files变量。

0 个答案:

没有答案