Created
October 28, 2021 10:14
-
-
Save RamiAwar/a14ad1706127ef2c0737b54bbb1d4220 to your computer and use it in GitHub Desktop.
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
def verify_image(file): | |
"""Verifies that file is a valid image""" | |
return file.ext in ("jpg", "jpeg", "png") | |
def store_file(file): | |
"""Upload file to storage microservice""" | |
return storage_service.upload_image(file) | |
def upload_image(file): | |
"""API route to upload image""" | |
if verify_image(file): | |
store_file(file) | |
else: | |
raise HTTPException(400, "Invalid image") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment