diff options
Diffstat (limited to 'utils.py')
| -rw-r--r-- | utils.py | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/utils.py b/utils.py deleted file mode 100644 index 023c838..0000000 --- a/utils.py +++ /dev/null | |||
| @@ -1,33 +0,0 @@ | |||
| 1 | import os | ||
| 2 | import hashlib | ||
| 3 | |||
| 4 | |||
| 5 | def get_allow_origin_header_value(): | ||
| 6 | return os.environ.get('MAT2_ALLOW_ORIGIN_WHITELIST', '*').split(" ") | ||
| 7 | |||
| 8 | |||
| 9 | def hash_file(filepath: str) -> str: | ||
| 10 | sha256 = hashlib.sha256() | ||
| 11 | with open(filepath, 'rb') as f: | ||
| 12 | while True: | ||
| 13 | data = f.read(65536) # read the file by chunk of 64k | ||
| 14 | if not data: | ||
| 15 | break | ||
| 16 | sha256.update(data) | ||
| 17 | return sha256.hexdigest() | ||
| 18 | |||
| 19 | |||
| 20 | def check_upload_folder(upload_folder): | ||
| 21 | if not os.path.exists(upload_folder): | ||
| 22 | os.mkdir(upload_folder) | ||
| 23 | |||
| 24 | |||
| 25 | def return_file_created_response(output_filename, mime, key, meta, meta_after, download_link): | ||
| 26 | return { | ||
| 27 | 'output_filename': output_filename, | ||
| 28 | 'mime': mime, | ||
| 29 | 'key': key, | ||
| 30 | 'meta': meta, | ||
| 31 | 'meta_after': meta_after, | ||
| 32 | 'download_link': download_link | ||
| 33 | } | ||
