split form upload and wx upload, refactor file structure

This commit is contained in:
moicen
2022-06-26 14:30:59 +08:00
committed by 木逸辰
parent ef205b12c8
commit 8ee4eb11ea
15 changed files with 450 additions and 112 deletions
+32
View File
@@ -0,0 +1,32 @@
-- 指定模块引用目录,否则无法加载同目录下的其他文件
--package.path = package.path .. ';/usr/local/opt/openresty/nginx/scripts/?.lua';
package.path = package.path .. ';<SCRIPT_PATH>/?.lua';
local cjson = require "cjson"
local get_wx_media = require("wx_download")
local create_task = require("create_task")
local verify = require('jwt_verify')
local authHeader = ngx.req.get_headers().Authorization
local sudoerToken = ngx.req.get_headers().HtySudoerToken
verify(authHeader, sudoerToken)
local function read_wx_file()
ngx.req.read_body()
local req_body = cjson.decode(ngx.req.get_body_data())
ngx.log(ngx.INFO, 'REQ_BODY -> ', ngx.req.get_body_data())
local files = {}
for v in pairs(req_body["payload"]["media_ids"]) do
table.insert(files, get_wx_media(v));
end
create_task(files, authHeader, sudoerToken)
end
read_wx_file()