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

Can this work with ngx.req.get_post_args() #14

Open
ryannining opened this Issue Mar 28, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@ryannining

ryannining commented Mar 28, 2015

I have some code like this

    ngx.ctx.uploads={} --m.getupload()
    ngx.req.read_body()
    ngx.ctx.posts={}
    args, err = ngx.req.get_post_args()
    for key, val in pairs(args) do
        ngx.ctx.posts[key]=val
        ngx.ctx.gets[key]=val

and m.getupload is using your library, to get all the uploads into table hashed by the input_name. it also save the non file data input to table posts

getupload:->
    form = upload\new(100000)
    file_name=""
    input_name=""
    resx=""
    result={}
    while form~=nil do
      typ, res, err = form\read()
      if typ == "header" then
        if res[1]=="Content-Disposition"
          tt=m.getfield(res)
          file_name = tt.filename
          input_name = tt.name
          resx=""

      elseif typ == "eof"
        break  
      elseif typ == "body"
        if input_name
          resx=resx..res

      elseif typ == "part_  "
        if file_name
          result[input_name]={file_name,resx}
          ngx.ctx.gets[input_name]=file_name
        else
          ngx.ctx.gets[input_name]=resx

        resx=""

if i enable uploads processing then the ngx.req.get_post_args() not work. perhaps i need to detect the enc-type multipart ?

@agentzh

This comment has been minimized.

Show comment
Hide comment
@agentzh

agentzh Mar 28, 2015

Member

@ryannining Yes, you need to test the MIME type before taking any action. lua-resty-upload implements its own request body reader while ngx.req.read_body() uses nginx's request body reader.

Member

agentzh commented Mar 28, 2015

@ryannining Yes, you need to test the MIME type before taking any action. lua-resty-upload implements its own request body reader while ngx.req.read_body() uses nginx's request body reader.

@ryannining

This comment has been minimized.

Show comment
Hide comment
@ryannining

ryannining Mar 28, 2015

Still cant find how to test the mime, please help me

ryannining commented Mar 28, 2015

Still cant find how to test the mime, please help me

@agentzh

This comment has been minimized.

Show comment
Hide comment
@agentzh

agentzh Mar 28, 2015

Member

@ryannining You can just try calling resty.upload's new() method first. Which performs the MIME test. If the test fails, new() returns nil with an error string.

Under the hood, it just checks the Content-Type request header.

Member

agentzh commented Mar 28, 2015

@ryannining You can just try calling resty.upload's new() method first. Which performs the MIME test. If the test fails, new() returns nil with an error string.

Under the hood, it just checks the Content-Type request header.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment