lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, Sep 27, 2011 at 21:26, Sebastien Lai <237482@googlemail.com> wrote:
> Hello dear readers of the Lua mailinglist,
>
> I just wanted to let you folks know that LunarCGI
> (http://github.com/beelzebub/lunarcgi) finally supports fileuploads!
>
> A big thanks goes to the LuaCheia project, whose multipart parsing
> functions I borrowed, and zash (freenode) for kindly helping me out
> with parsing the data correctly.
>
> It's almost flawless (that is, I haven't found any flaws so far, so
> keep testing and reporting guys), and semantically, it differs from
> PHP and Perl in terms of usability quite a bit. I find it easier to
> use, that is.
>
> The value returned from LunarCGI#paramMULTIPART(<key>) is structured
> as follows (shamelessly ripped from the comments from LunarCGI.lua):
>
>    -- if a file is uploaded:
>    -- {
>    --    isfile = true;
>    --    name = <fieldname>;
>    --    filename = <filename>;
>    --    data = <filedata>;
>    --    headers = {
>    --        type = <contenttype>;
>    --        charset = <charset> or nil;
>    --    }
>    -- }
>    -- if a simple var is posted:
>    -- {
>    --     name = <fieldname>;
>    --     data = <postdata>;
>    --     isfile = false;
>    -- }
>
> The function LunarCGI#queriesMULTIPART() returns all vars found via
> multipart parsing. So far one can upload several files at once without
> any problems (and I admit, i'm kind of proud of it :-P).
>
> Of course, this would have not been possible without the help of the
> very kind Lua community. So a big thanks to everyone who has helped
> once again :-)
>
> One could say that this is a big step for LunarCGI, but a small step
> for web programming :-)
>
>

So uploading a 100MB file will consume 100MB of RAM? There's a good
reason PHP just gives you a handle to a temporary file and a way to
move it.

-- 
Sent from my toaster.