This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
5
How to send File Response ?
Post Flair (click to view more posts with a particular flair)
Post Body
My client side is mobile I am able to send image to python
Python does image manipulation and sends file back
But the problem is how do I process it on client side do I need to send file response as bytes to client side or what
Honestly I am so confused and spent whole day on trying to make it work so any help would be amazing
Edit - my fastApi code
@app.post('/uploadImage/', tags=['Images'],) async def get_image( image: List[UploadFile] = File(),):
# im = Image.open("hopper.ppm")
# newImage = await merge(image[0],image[1])
file_location = f"image1.jpeg"
file_location2 = f"image2.jpeg"
with open(file_location, "wb ") as file_object:
file_object.write(image[0].file.read())
with open(file_location2, "wb ") as file_object:
file_object.write(image[1].file.read())
im1 = Image.open("image1.jpeg")
im2 = Image.open("image2.jpeg")
new_image = ImageChops.multiply(im1, im2)
new_image.save(fp='newImage.jpeg')
return {
'File Response':FileResponse('"newImage.jpeg"',filename='mergedImage.jpeg')
}
Author
Account Strength
100%
Account Age
4 years
Verified Email
Yes
Verified Flair
No
Total Karma
1,398
Link Karma
728
Comment Karma
473
Profile updated: 2 days ago
Posts updated: 11 months ago
Subreddit
Post Details
We try to extract some basic information from the post title. This is not
always successful or accurate, please use your best judgement and compare
these values to the post title and body for confirmation.
- Posted
- 2 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/FastAPI/com...