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

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -