Skip to content

Commit baebf53

Browse files
authored
Fix supported formats
1 parent 3f80b80 commit baebf53

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

calendar_backend/methods/image.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@
1616
from calendar_backend.settings import get_settings
1717

1818

19-
SUPPORTED_FILE_EXTENSIONS: Final[list[str]] = ['png', 'svg', 'jpg', 'jpeg']
2019
settings = get_settings()
2120

2221

2322
async def upload_lecturer_photo(lecturer_id: int, session: Session, file: UploadFile = File(...)) -> Photo:
2423
lecturer = Lecturer.get(lecturer_id, session=session)
2524
random_string = ''.join(random.choice(string.ascii_letters) for _ in range(32))
2625
ext = file.filename.split('.')[-1]
27-
if ext not in SUPPORTED_FILE_EXTENSIONS:
26+
if ext not in settings.SUPPORTED_FILE_EXTENSIONS:
2827
raise HTTPException(status_code=422, detail="Unsupported file extension")
2928
filename = f"{random_string}.{ext}"
3029
path = os.path.join(settings.STATIC_PATH, "photo", "lecturer", filename)

calendar_backend/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class Settings(UnionAuthSettings, BaseSettings):
2626
CORS_ALLOW_CREDENTIALS: bool = True
2727
CORS_ALLOW_METHODS: list[str] = ['*']
2828
CORS_ALLOW_HEADERS: list[str] = ['*']
29+
SUPPORTED_FILE_EXTENSIONS: list[str] = ['png', 'svg', 'jpg', 'jpeg', 'webp']
2930

3031
class Config:
3132
"""Pydantic BaseSettings config"""

0 commit comments

Comments
 (0)