Conversation
lib/resty/requests/multipart.lua
Outdated
| @@ -0,0 +1,330 @@ | |||
| --https://github.com/pytpeng/lua-multipart | |||
There was a problem hiding this comment.
Why not just manage this dependency by LuaRocks/OPM rather than copy it.
There was a problem hiding this comment.
upstream code not merge my pull request yet,so left the problem,Kong/lua-multipart#27
There was a problem hiding this comment.
I think we should suspend this MR until your MR merged by Kong.
| if json then | ||
| content = cjson.encode(json) | ||
| headers["content-length"] = #content | ||
| headers["content-type"] = "application/json" |
There was a problem hiding this comment.
Better to leave an empty line here.
lib/resty/requests/request.lua
Outdated
| if not content_type then | ||
| content_type = "multipart/form-data; boundary="..util.choose_boundary() | ||
| end | ||
| local multipart_body= util.make_multipart_body(files, content_type) |
There was a problem hiding this comment.
Style: a space character should be kept before =.
| local multipart_body= util.make_multipart_body(files, content_type) | ||
| headers["content-type"] = content_type | ||
| headers["content-length"] = #multipart_body | ||
| content = multipart_body |
lib/resty/requests/util.lua
Outdated
| local tostring = tostring | ||
| local ngx_gsub = ngx.re.gsub | ||
| local base64 = ngx.encode_base64 | ||
| local Multipart = require("resty.requests.multipart") |
There was a problem hiding this comment.
Well, please keep all require statements at the top of file, also, do not use capital letters.
lib/resty/requests/util.lua
Outdated
| config.body = opts.body | ||
|
|
||
| -- 4.1) files | ||
| config.files = opts.files |
There was a problem hiding this comment.
Since we add an extra to config, adjusting the table slot size is necessary.
| local function choose_boundary() | ||
| return str_sub(tostring({}), 10) | ||
| end | ||
|
|
There was a problem hiding this comment.
Two empty lines are needed to separate functions.
lib/resty/requests/util.lua
Outdated
| for _, v in ipairs(files) do | ||
| m:set_simple(v[1], v[2], v[3], v[4]) | ||
| local m = multipart("", content_type) | ||
| for i=1,#files do |
There was a problem hiding this comment.
Style: keep a space before #files.
There was a problem hiding this comment.
@pytpeng
Could you add some test cases to cover this feature?
yeah
|
@pytpeng |
…ltipart by LuaRocks/OPM
no message
no message
|
Add the test cases already 👌
发自我的iPhone
在 2020年3月23日,12:32,Alex Zhang <notifications@github.com> 写道:
@pytpeng<https://github.com/pytpeng>
Could you add some test cases to cover this feature?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#32 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AHBHDT46KWJFPKVM3BV6TEDRI3Q65ANCNFSM4LRG3TKA>.
|
|
@pytpeng |
|
@pytpeng |
|
@tokers |
add new feature==>support multipart/form ,so we can upload file by requests like python requests