如何从基于 twilio link 的 amezon 服务器下载图像?

How to download image from amezon server base on twilio link?

我正在使用 twilio 发送和接收短信和彩信。 在此我们从客户那里获得彩信重播,通过短信我们从 twilio 获得图像 link,下面是示例: http://media.twiliocdn.com.s3-external-1.amazonaws.com/AC70edf98a96171fd173a06c91f9866e44/7f05c776f706eb9265f74f2236ac146c

在此我们要在我们的服务器上下载这张图片。那么有人知道如何做到这一点吗?

我在这个 blog post 中遇到了类似的情况,我在发送回之前使用我的本地文件系统操作了 URL 中存储的文件。

Python 中的片段:

if request.form['NumMedia'] != '0':
    filename = request.form['MessageSid'] + '.jpg'
    f = open(filename, 'wb')
    f.write(requests.get(request.form['MediaUrl0']).content)
    f.close()

我在 python 请求库中检查 parameters to make sure that the media is indeed there with NumMedia and I believe in PHP you would use the fopen() function then $_REQUEST[‘MediaUrl0′] to retrieve the image and whatever the PHP equivalent is for binary response content 以写入非文本正文。

希望对您有所帮助!