summaryrefslogtreecommitdiff
path: root/foreign/client_handling/download.py
diff options
context:
space:
mode:
Diffstat (limited to 'foreign/client_handling/download.py')
-rw-r--r--foreign/client_handling/download.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/foreign/client_handling/download.py b/foreign/client_handling/download.py
new file mode 100644
index 0000000..d88f3f5
--- /dev/null
+++ b/foreign/client_handling/download.py
@@ -0,0 +1,9 @@
+import os
+
+
+def download(filename, max_file_size):
+ if (os.path.getsize(filename) / 1024 / 1024) > max_file_size:
+ return {'message': f'File exceeding maximum size of {max_file_size}MB', 'download': None, 'text_mode': 'danger'}
+
+ with open(filename, 'rb') as f:
+ return {'message': f'{filename} succesfully downloaded', 'download': f.read(), 'text_mode': 'success'} \ No newline at end of file