I made a small server with flask to upload files (and then do stuff with them). The upload is through and HTML form that sends a file:
<form action="/upload" method="POST" enctype="multipart/form-data">
<input type="file" name="file">
<input type="submit">
</form>
On the server side I do the following:
@app.route('/upload', methods=['POST'])
def upload():
if 'file' in request.files:
f = request.files['file']
file_path = os.path.join(app.config['UPLOAD_FOLDER'], werkzeug.secure_filename(f.filename))
f.save(file_path)
return 'File is being uploaded'
It works fine for small files but on large files, it fails. The problem is that if I run the script manually not through gunicorn python main.py I can upload files that I couldn't before. I thought I needed to change the max size in gunicorn but couldn't find how to do it.
I also thought to use a stream and then write chunks but again, I couldn't find how to access the stream with flask.
Thanks for your help