I have a Rails app server. I want to build a Python client that uploads an image.
I want to do something like this:
def add_photo(entry_id, image_path):
return requests.post(
url = URL,
headers = HEADER,
json = {
'entry': {
'entry_id': entry_id,
}
},
files = {
"entry['photo']": (
os.path.basename(image_path),
open(image_path, 'rb'),
'image/jpg',
{'Expires': '0'}
)
}
)
I need the image nested into the 'entry' key. The above code does not work because the key "entry['photo']"
isn't valid.
How do I do this?
Thank you so much for your help!