刚才用
local upload = require "resty.upload"
local cjson = require "cjson"
local chunk_size = 5 -- should be set to 4096 or 8192
-- for real-world settings
local form = upload:new(chunk_size)
form:set_timeout(1000) -- 1 sec
while true do
local typ, res, err = form:read()
if not typ then
ngx.say("failed to read: ", err)
return
end
ngx.say("read: ", cjson.encode({typ, res}))
if typ == "eof" then
break
end
end
local typ, res, err = form:read()
ngx.say("read: ", cjson.encode({typ, res}))
这段代码测试了一下,明白其中的原理了。
呵呵
"Content-Disposition","form-data; name=\"name\""]
这样的,就表示是TEXT组件
Content-Disposition","form-data; name=\"file\"; filename=\"sn.txt\""]
这样的,就表示是file组件了。
下面就可以分别使用lua代码分开进行处理。
agentzh,我说的对吗?