From f1cfaef5b0f358c94fe7f5e7c2eb5a6d261a85ae Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sat, 7 Dec 2019 11:14:01 +0100 Subject: Add max file size configuration This allows configuring max file sizes for both registered and anonymous users. For registered users the USER_FILE_SIZE_LIMIT is used, and ANONYMOUS_FILE_SIZE_LIMIT for anonymous users. If the size is not specified or None, the limit is not enforced. Setting the limit to 0 effectively disables uploads. --- fbin/file_storage/filesystem.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'fbin/file_storage/filesystem.py') diff --git a/fbin/file_storage/filesystem.py b/fbin/file_storage/filesystem.py index 1259002..07d29db 100644 --- a/fbin/file_storage/filesystem.py +++ b/fbin/file_storage/filesystem.py @@ -22,7 +22,8 @@ class Storage(BaseStorage): size = os.path.getsize(temp_path) try: new_file = self.add_file(file_hash, uploaded_file.filename, size, user, ip) - os.rename(temp_path, new_file.get_path()) + if new_file: + os.rename(temp_path, new_file.get_path()) return new_file except: os.unlink(temp.name) -- cgit v1.2.3