Created
May 10, 2019 16:41
-
-
Save muthuspark/d1c0d567ac295a796b011a5d0fb33b4c to your computer and use it in GitHub Desktop.
upload image from local file - python request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import requests | |
img_to_upload = '/Users/muthukrishnan/Pictures/15566790261881556159500299IMG_20190330_120119.jpg' | |
url = "http://localhost:5000/api/document/page-extract" | |
uploaded_img_path = '' | |
with open(img_to_upload, 'rb') as img: | |
name_img = os.path.basename(img_to_upload) | |
files = { | |
'file': (name_img,img,'multipart/form-data', {'Expires': '0'}) | |
} | |
with requests.Session() as s: | |
r = s.post(url,files=files) | |
uploaded_img_path = r.json()['image'] | |
print(uploaded_img_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment