werkzeug
werkzeug copied to clipboard
Keeping file uploads in memory
Inside of default_stream_factory, is a way I can add a setting such that I can set the threshold of how large total_content_length can be before it writes to a temporary file?
Are there settings (and examples of such) that I can see and hence patch this myself?
Or am I forced to fork werkzeug to implement my own method?
def my_stream_factory(total_content_length, filename, content_type, content_length=None):
... # do something special
class MyFormDataParser(FormDataParser):
def __init__(self, *args, **kwargs):
kwargs.setdefault("stream_factory", my_stream_factory)
super().__init__(*args, **kwargs)
class MyRequest(Request):
form_data_parser_class = MyFormDataParser
class MyFlask(Flask):
request_class = MyRequest