feat(插件): 读取附件正文并保留日志文本
新增附件读取测试插件并配置上传路径,记录文件名、提取状态及正文。所有插件日志保留参数和级别,按字节限制截断并转义换行,补充运行时和附件集成测试。
This commit is contained in:
1 parent
4e0d46ff5f
commit
016c43f13e
9 files changed
+174
-9
No files matched your search
@@ -0,0 +1,19 @@
|
||||
-- 上传附件读取测试:通过 host.files 读取提取正文,不改写请求或文件。
|
||||
-- 场景运行器追加 --verbose 即可显示 INFO 日志。
|
||||
local plugin = {}
|
||||
|
||||
function plugin.on_request(ctx, request)
|
||||
if request.kind ~= "multipart" then return {action = "pass"} end
|
||||
for _, file in ipairs(request.files or {}) do
|
||||
local text = host.files.read_text(file.id)
|
||||
host.log.info(host.json.encode({
|
||||
name = file.name,
|
||||
extraction_status = file.extraction_status,
|
||||
text_bytes = file.text_bytes,
|
||||
text = text,
|
||||
}))
|
||||
end
|
||||
return {action = "pass"}
|
||||
end
|
||||
|
||||
return plugin
|
||||
Reference in new issue
Block a user