-
Notifications
You must be signed in to change notification settings - Fork 113
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
support decode the multipart form data as lua table #7
base: master
Are you sure you want to change the base?
Conversation
It would be nice to check the content size before/in process decoding. And huge fields is better be saved to files, not in-memory table. May be something like this. |
@Seayea I'm not sure if it is a good thing to have in this library. The whole point of this library is strict non-buffered processing of big upload data. If we add this full buffering API then we are actually encouraging the user to use the full-buffered processing method, which is very expensive. |
Yeah. I think your comments will cover the cases which mainly aimed to upload files, and will save memory. |
@agentzh, I agree with you that this full-buffered way is expensive. I use this API just for files not so big. Maybe I should submit one more warning for using this API. It's up to you to decide if this is valuable to be in the main track. I'm not sure as well if there is any more user's have the needs as me. |
@Seayea I'll hold this for a little while until more users ask for it :) Thank you for the contribution! |
i think we should put this in another lua-resty-* like library and we are badly need something like bower or component which will scan github project which has something openresty.json to index the lua-resty packages, but with quality verified attribute as addition, imho. |
@antonheryanto Yes, I agree we need a central place for 3rd-party lua-resty-* libraries :) |
I have been using pjax (https://github.com/defunkt/jquery-pjax). The only supported way in pjax to post forms is throught JS FormData which is |
@bungle actually already handle that in my library lua-resty-post which convert application/x-www-form-urlencoded, application/json and multipart/form-data into lua table. it save file into temporary files (which path configurable) and provides info files info like PHP |
@antonheryanto thanks for reminding about it. I wish I had remembered this yesterday, as I already went ahead and build a new one for my lua-resty-route project: https://github.com/bungle/lua-resty-route/blob/master/lib/resty/route/middleware/form.lua (that could be generalized). The code needs a bit cleaning up and support for json and urlencoded, but they are the easy part of this. Looks like we went almost the same route here, :-). |
This is what I finally ended up: There are room for improvements still (but I'll look those later):
Looks very similar to @antonheryanto's lua-resty-post, |
Add support of decoding the multipart form data as lua table.
By this feature, we can get the lua table which contains the fields from the submitted multipart form data; and operate on them within LUA script.
Currently, support the Content-Disposition and Content-Type header.
May submit more header support.