2012-10-09 29 views
0
發送

我的網址太長,它拋出我的錯誤:如何將圖像的位由requests.post(URL,數據)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)使我上面提到的錯誤

+0

您可能想要顯示一些代碼,瞭解如何執行此操作。它看起來像是在嘗試對圖像進行編碼並將其發送到POST網址,這會使網址過長。你想把圖像放在POST數據中。 – dragonx

+0

當您像發佈圖片一樣發佈數據時,您必須將其作爲有效負載中的多部分消息發佈。看到這個問題:http://stackoverflow.com/questions/10066540/post-request-with-multipart-form-data-in-appengine-python-not-working 看着你的代碼。您從表單中收到圖像。你爲什麼不把圖像上傳到你的服務器? https://developers.google.com/appengine/docs/python/blobstore/overview#Uploading_a_Blob – voscausa

回答

0

嗨,大家好,錯誤發生是因爲它沒有很好地介紹我的模型中的數據類型,以及稍後因爲他們理解錯誤消息對我沒有多大幫助,並且我相信錯誤在其他地方有感謝您的反饋。