pegasus.lua
pegasus.lua copied to clipboard
support to file upload(plugin)
Api: table_files = request.get_files()
API:
- content_type_filter = {"jpg", png"}
- content_type_discover={ "file_type","file_extension"}
- destination = "image/"
- min_ body_size = 1048576
- max_body_size = 1048576
- file
Here is a patch to the master branch which adds basic multi-part form parsing capability (and so file uploads too). It's not implemented as a plugin and, frankly, I have no idea how that would even be done without extreme breaking changes.
Unlike other parameters, files have more data than just their name and value, so they are stored in the post data as tables. The rest is as it were to maintain backwards-compatibility. Find in request:post()
.
I do not recommend using this in production. I'm certain malicious input is still capable of crashing it, and there's not even a max file or max content size. At least it exists, which is more than can be said for the file uploading plugin.
Looking for input on implementation, before this is polished and potentially pushed in.