openresty / openresty/lua-resty-upload

Can this work with ngx.req.get_post_args()

Open
#14 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
414
Forks
110
Avg merge
2h 43m
Merged PRs (30d)
1

Description

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 ?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the upload library's form:read() flow and the ngx.req.get_post_args() call shown in the issue, focusing on how multipart request bodies are handled. Determine whether both APIs can process the same request and whether content-type detection is required; document the supported behavior and any necessary usage guidance.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, nginx
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.