-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a max_size parameter to save and _copy_file #1326
base: master
Are you sure you want to change the base?
Conversation
…ethod of FileUpload.
I like this idea. It's super minor, but why use a keyword argument on a private method? It certainly doesn't hurt though and, like I said, this is minor. |
Thank you. That is a good point – the function signature of a private method can be controlled within this library. OTOH, if
The former has the downside that then the order in the signature differs from the order in the signature of The latter might have the downside that then the default value of So, I am obviously fine with anything that seems acceptable to the maintainers. |
Further possible points of critique may be (in no prioritizing order):
|
This is somewhat related but I couldn't find information on whether there is some hard limitation to file upload size? Can this method support upload for 2GB+ files? This appears to fail in my case on Raspberry PI. So is the current method using RAM? if not, why would it fail on raspberry PI? |
Probably because your |
It's not, this is on Raspberry PI 16GB SD card and /tmp is just not size restricted as far as I know.
|
oh I see, which of the tmpfs above is used by the Python/Bottle framework? is it the last entry which 790MB available size? this is why it fails? What's the workaround for such a case? Thanks!! |
Bottle uses Bottle does not do any in-memory buffering of file uploads. The whole body is buffered, but only for requests smaller than |
Thanks. Under Linux, gettempdir is indeed /tmp. /tmp does not appear to be mounted to any tmpfs as per the |
This is a proposal inspired by a requirement I had myself and by the following comment on Stack Overflow: “Bottle stores file uploads in request.files as FileUpload instances, along with some metadata about the upload. FileUpload has a very handy save method that perform the "file slurping" for you. It does not check the maximum file upload though, but IMHO it's better to have nginx in front to perform this kind of limitation check.”
If you don’t use nginx or so and want to have an upper limit for the file size, it would be nice if the save method had an additional parameter max_size to set a maximum size beyond which the writing is stopped.
The changes in this branch hopefully enable that and I wanna propose to merge them.