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
Post a Comment