Skip to content

Instantly share code, notes, and snippets.

@RamiAwar
Created October 28, 2021 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RamiAwar/a14ad1706127ef2c0737b54bbb1d4220 to your computer and use it in GitHub Desktop.
Save RamiAwar/a14ad1706127ef2c0737b54bbb1d4220 to your computer and use it in GitHub Desktop.
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