can we count the upload filesize before uploading in python-flask


Question

I have a simple flask app where i am uploading single file but with file size of less than 5MB
for that i have defined
if request.content_length < 5.250e+6: ## setting upload limit to 5MB test case in my flask-app; but this is verifying the file size after uploading it; or may be i am wrong.
so is there any way to get the file size before uploading it???

Here is python solution on python+GAE, but i am new to python web framework; i know very little in flask
and this solution is based on webapp2 which is very complicated for me and also its on GAE; that is another story. so can anyone generate its flask equivalent or any other possible way to do it in flask???

1
1
12/22/2012 6:16:17 AM

Flask is able to limit file size while upload is in progress, see the documentation. All you need is to set MAX_CONTENT_LENGTH when configuring your app.

3
12/22/2012 12:30:04 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon