【发布时间】:2012-10-09 16:15:09
【问题描述】:
我的网址太长,它会抛出错误:
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) 犯了我上面提到的错误
【问题讨论】:
-
您可能想展示一些代码来说明您是如何执行此操作的。看起来您正在尝试对图像进行编码并将其发送到 POST url,这很容易使 URL 太长。您想将图像放入 POST 数据中。
-
当您像图像一样发布数据时,您必须将其作为多部分消息发布在有效负载中。看到这个问题:stackoverflow.com/questions/10066540/… 查看您的代码。您从表单中收到图像。为什么不将图像上传到服务器? developers.google.com/appengine/docs/python/blobstore/…