2025-10-15 10:35:42 +08:00
|
|
|
---
|
|
|
|
|
--- Generated by EmmyLua(https://github.com/EmmyLua)
|
|
|
|
|
--- Created by admin.
|
|
|
|
|
--- DateTime: 2025/10/15 09:12
|
2025-10-17 10:16:13 +08:00
|
|
|
---
|
|
|
|
|
|
|
|
|
|
--读取请求体的数据
|
|
|
|
|
ngx.req.read_body()
|
|
|
|
|
|
|
|
|
|
--获取请求数据
|
|
|
|
|
local body_data = ngx.req.get_body_data()
|
|
|
|
|
|
|
|
|
|
if not body_data then
|
|
|
|
|
ngx.say("read file error:"..err)
|
|
|
|
|
return ngx.exit(400)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
ngx.say(body_data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--local cjson = require("cjson")
|
|
|
|
|
--local file_path = "/home/frankly/work/test.dat"
|
|
|
|
|
--local file_length = 1024 * 1024 * 380
|
|
|
|
|
--local f, err = io.input(file_path, "r")
|
|
|
|
|
--if not f then
|
|
|
|
|
-- ngx.say("read file error:"..err)
|
|
|
|
|
-- return
|
|
|
|
|
--end
|
|
|
|
|
--local content = f:read(file_length) --读取文件内容
|
|
|
|
|
--f:close() --关闭文件
|
|
|
|
|
----ngx.say(content)
|
|
|
|
|
--local res = {
|
|
|
|
|
-- key = "data",
|
|
|
|
|
-- value = content
|
|
|
|
|
--}
|
|
|
|
|
--ngx.header["Content-Type"] = 'application/json; charset=UTF-8'
|
|
|
|
|
--ngx.say(cjson.encode(res))
|