Sending Image in Multipart to FastAPI Endpoint from Python

Abhay Shukla
Feb 9, 2021

--

The code is in the gist below:

It is quite straightforward, isn’t it? When you are preparing input instead of file_path you can also give name of the file or any default value as well. In that case, the input changes as:

files = {‘file’: (“some_useful_name”, open(file_path, ‘rb’), “image/jpeg”)}

That’s it!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Abhay Shukla
Abhay Shukla

Written by Abhay Shukla

Data Science @ Meesho, Ex- Airtel, Swiggy, [24]7.ai https://www.linkedin.com/in/shuklaabhay/ #DataScience #ML #AI #Statistics #Reading #Music #Running

No responses yet

Write a response