Can't upload image by POST method from url. Python -


i can't send image object in multipart/form-data format without writing , reading on disk. method not work:

    response = requests.get(offer['picture'])     if not response.ok:         print('error!', response)         continue     image = response.content     response = requests.post(upload_url, files={'file': image}) 

api thinks image small. method works:

    response = requests.get(offer['picture'])     if not response.ok:         print('error!', response)         continue     image = response.content     open('test.jpg', 'wb') file:         file.write(image)     response = requests.post(upload_url, files={'file': open('test.jpg', 'rb')}) 

how can upload image without writing on disk?

working code:

response = requests.get(offer['picture']) if not response.ok:     print('error!', response)     continue image = response.content response = requests.post(upload_url, files={'file': ('image.jpg', image)}) 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -