add init copy
This commit is contained in:
@@ -1,38 +1,21 @@
|
||||
-- 指定模块引用目录,否则无法加载同目录下的其他文件
|
||||
--package.path = package.path .. ';/usr/local/opt/openresty/nginx/scripts/?.lua';
|
||||
package.path = package.path .. ';<SCRIPT_PATH>/?.lua';
|
||||
|
||||
local cjson = require "cjson"
|
||||
local http = require 'resty.http'
|
||||
local pl = require "pl.pretty"
|
||||
local get_wx_media = require("wx_download")
|
||||
local create_task = require("lib.create_task")
|
||||
local verify = require('lib.jwt_verify')
|
||||
local http = require "resty.http"
|
||||
local create_task = require "lib.create_task"
|
||||
local TaskTypes = require 'lib.task_type'
|
||||
local httpc = http:new()
|
||||
|
||||
local verify = require('lib.jwt_verify')
|
||||
|
||||
local authHeader = ngx.req.get_headers().Authorization
|
||||
local sudoerToken = ngx.req.get_headers().HtySudoerToken
|
||||
verify(httpc, authHeader, sudoerToken)
|
||||
|
||||
local httpc = http.new()
|
||||
ngx.req.read_body()
|
||||
local req_body = cjson.decode(ngx.req.get_body_data())
|
||||
print('req_body...', ngx.req.get_body_data())
|
||||
local media_id = req_body['media_id']
|
||||
|
||||
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 i = 1, #req_body["media_ids"] do
|
||||
print("media_id -> ", i, req_body["media_ids"][i])
|
||||
local _, filename = get_wx_media(httpc, req_body["media_ids"][i], cjson, pl)
|
||||
table.insert(files, filename);
|
||||
end
|
||||
local task_text = cjson.encode({ task_type = TaskTypes.UPLOAD_PICTURE, payload = { images = files } })
|
||||
create_task(httpc, task_text, authHeader, sudoerToken)
|
||||
|
||||
end
|
||||
local task_text = cjson.encode({ task_type = TaskTypes.CONVERT_AUDIO_FILE, payload = { media_id = media_id } })
|
||||
create_task(httpc, task_text, authHeader, sudoerToken)
|
||||
|
||||
|
||||
read_wx_file()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user