From b36f9c05071ea549ed59e703270fcf223b60df03 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sun, 9 Apr 2017 09:02:09 +0200 Subject: Major rewrite to use jab/oauth. Highlights: - Uses the oauth branch of jab. - Changed design to use bootstrap. - Some minor changes to functionality in file uploading and listing. - API is currently disabled and incomplete. --- fbin/monkey.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 fbin/monkey.py (limited to 'fbin/monkey.py') diff --git a/fbin/monkey.py b/fbin/monkey.py new file mode 100644 index 0000000..c6458ad --- /dev/null +++ b/fbin/monkey.py @@ -0,0 +1,25 @@ +import tempfile + +from flask import current_app +import werkzeug.formparser +import werkzeug.wrappers + +def werkzeug_patch(): + global werkzeug_orig_stream_factory + + werkzeug_orig_stream_factory = werkzeug.formparser.default_stream_factory + + def custom_stream_factory(total_content_length, filename, content_type, content_length=None): + if total_content_length > 1024 * 500: + return tempfile.NamedTemporaryFile('wb+', prefix = 'upload_', dir = current_app.config['FILE_DIRECTORY'], delete = True) + return werkzeug_orig_stream_factory(total_content_length, filename, content_type, content_length) + + werkzeug.formparser.default_stream_factory = custom_stream_factory + werkzeug.wrappers.default_stream_factory = custom_stream_factory + +def werkzeug_reset(): + werkzeug.formparser.default_stream_factory = werkzeug_orig_stream_factory + werkzeug.wrappers.default_stream_factory = werkzeug_orig_stream_factory + +def patch(): + werkzeug_patch() -- cgit v1.2.3