aboutsummaryrefslogtreecommitdiff
path: root/qc_app/files.py
diff options
context:
space:
mode:
Diffstat (limited to 'qc_app/files.py')
-rw-r--r--qc_app/files.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/qc_app/files.py b/qc_app/files.py
index baac5ec..b163612 100644
--- a/qc_app/files.py
+++ b/qc_app/files.py
@@ -1,17 +1,15 @@
"""Utilities to deal with uploaded files."""
import hashlib
from pathlib import Path
-from typing import Union
from datetime import datetime
from flask import current_app
from werkzeug.utils import secure_filename
from werkzeug.datastructures import FileStorage
-def save_file(fileobj: FileStorage, upload_dir: Path) -> Union[Path, bool]:
+def save_file(fileobj: FileStorage, upload_dir: Path) -> Path:
"""Save the uploaded file and return the path."""
- if not bool(fileobj):
- return False
+ assert bool(fileobj), "Invalid file object!"
hashed_name = hashlib.sha512(
f"{fileobj.filename}::{datetime.now().isoformat()}".encode("utf8")
).hexdigest()