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
|
|
|
|
---
|
|
|
|
|
|
|
2025-10-21 11:09:40 +08:00
|
|
|
|
local calc = require("util.snowalgorithm")
|
|
|
|
|
|
local dataCenterId = 1 -- 根据实际情况配置数据中心 ID 和机器 ID
|
|
|
|
|
|
local machineId = 1 -- 同理配置机器 ID,确保在所有机器中唯一且不超过最大值。
|
|
|
|
|
|
local id = calc.generateUuid(dataCenterId, machineId)
|
|
|
|
|
|
print("Generated UUID:", id)
|
|
|
|
|
|
|
2025-10-17 10:16:13 +08:00
|
|
|
|
--读取请求体的数据
|
|
|
|
|
|
ngx.req.read_body()
|
|
|
|
|
|
|
|
|
|
|
|
--获取请求数据
|
|
|
|
|
|
local body_data = ngx.req.get_body_data()
|
|
|
|
|
|
|
2025-10-17 15:43:19 +08:00
|
|
|
|
--if not body_data then
|
|
|
|
|
|
-- ngx.say("read file error:", err)
|
|
|
|
|
|
-- return ngx.exit(400)
|
|
|
|
|
|
--end
|
|
|
|
|
|
local len = #body_data
|
|
|
|
|
|
|
|
|
|
|
|
--local file_name = ngx.req.get_body_file()
|
|
|
|
|
|
ngx.say("file length:", len)
|
|
|
|
|
|
|
|
|
|
|
|
--ngx.req.read_body_in_buffer(ngx.var.request_body_file)
|
2025-10-17 10:16:13 +08:00
|
|
|
|
|
2025-10-17 15:43:19 +08:00
|
|
|
|
--ngx.say(body_data)
|
2025-10-17 10:16:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--local cjson = require("cjson")
|
|
|
|
|
|
--local file_path = "/home/frankly/work/test.dat"
|
2025-10-17 15:43:19 +08:00
|
|
|
|
--local file_length = 1024 * 1024 * 400
|
2025-10-17 10:16:13 +08:00
|
|
|
|
--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
|
|
|
|
|
|
--}
|
2025-10-17 15:43:19 +08:00
|
|
|
|
----ngx.header["Length"] = #content
|
2025-10-17 10:16:13 +08:00
|
|
|
|
--ngx.header["Content-Type"] = 'application/json; charset=UTF-8'
|
2025-10-17 15:43:19 +08:00
|
|
|
|
--ngx.say(cjson.encode(res))
|
|
|
|
|
|
--ngx.log(ngx.INFO, "send data success")
|