I have a code like this
Some Controller
def store_report():
try:
file = request.files.get('file')
upload_path = './storage/'
if allowed_file(file.filename):
file.save(os.path.join(upload_path, file.filename))
else:
return flask.abort(make_response(jsonify(status=400, message='File extension must be image'), 400))
return make_response(jsonify(status=200, message='Success'), 200)
except ValueError:
return flask.make_response(jsonify(message="Error when store", status=400), 400)
def allowed_file(filename):
return '.' in filename and \
filename.rsplit('.', 1)[1].lower() in {'png', 'jpg', 'jpeg'}
When i upload file < 500kb, i can get the request.files value. but when i upload >500kb the request.files return nothing or null.
What should i do, so i can upload bigger files?
I want to upload the bigger files for image recognition logic
from flask import Flask, Request
app = Flask(__name__)
app.config['MAX_CONTENT_LENGTH'] = 16 * 1000 * 1000
"The code above will limit the maximum allowed payload to 16 megabytes. If a larger file is transmitted, Flask will raise a RequestEntityTooLarge exception." - Flask Docs
Changing MAX_CONTENT_LENGTH should do the job