如何通过webapp2中的requests.post(url,data)发送图像的位

时间:2012-10-09 16:15:10

标签: google-app-engine webapp2

我的网址太长了,它让我错误:

ConnectionError: HTTPConnectionPool(host='xxxx', port=8086): Max retries exceeded with url: /user/profile?nick=nick&name=xxx&city=xxx&gender=x&profile_image=%FF%D8%FF%E0%00%10JFIF%00%01%01%01%00%60%00%60%00%00%...

我正在将图像上传到文件iput并尝试通过requests.post传递它,但它会抛出上面的错误。

我的代码是:

profile_image = self.request.get("f_profile_image")
    data = {"id": id_user,
                "nick": nick,
                "name": name,
                "last_name": last_name,
                "gender": gender,
                "profile_image": profile_image}

    d = requests.post("http://myhost:8086/user/profile",params=data)
    self.response.out.write(d.text)

我在这里得到了图片 profile_image = self.request.get(“f_profile_image”)我从表单发送,并尝试将其发送到我的服务器以存储在数据库中。但 d = requests.post(“http:// myhost:8086 / user / profile”,params = data)犯了我上面提到的错误

1 个答案:

答案 0 :(得分:0)

大家好,发生了错误,因为我的模型中没有引入良好的数据类型,后来因为他们理解错误消息对我没有多大帮助,而且我相信错误已经在别处感谢你的反馈。