-
-
Notifications
You must be signed in to change notification settings - Fork 376
Open
Description
I am new to lua.
A case, i was built a nginx + luajit +redis2.
I was used json.lua and got follow errer message:
2021/02/07 08:42:02 [error] 37#37: *11 failed to run body_filter_by_lua*: /etc/nginx/redis.lua:238: bad argument #1 to 'rawget' (table expected, got string)
stack traceback:
[C]: in function 'rawget'
/etc/nginx/redis.lua:238: in function 'decode'
/etc/nginx/ueditor/ueditor_upload_file_rewrite_response.lua:22: in function </etc/nginx/ueditor/ueditor_upload_file_rewrite_response.lua:1>
code fragments
if eof then
local whole = table.concat(ngx.ctx.buffered)
local ret_body = whole
if whole then
ngx.ctx.buffered = nil
local body_json = json.decode(whole) #################### line number 22 ####################
local ret_table = {}
if body_json then
ret_table['original'] = body_json['originalFilename']
ret_table['size'] = body_json['size']
ret_table['state'] = 'SUCCESS'
ret_table['title'] = body_json['originalFilename']:match("(.+)%.%w+$")
ret_table['type'] = body_json['file']:match(".+(%.%w+)$")
local imageUrl = body_json['thumbnail']
if imageUrl and imageUrl ~= "" then
ret_table['url'] = imageUrl
else
ret_table['url'] = body_json["file"]
end
else
ret_table['state'] = 'Error: upload file failed!'
end
ret_body = json.encode(ret_table)
end
ngx.arg[1] = ret_body
endAny help appreciated .
Thanks,
Metadata
Metadata
Assignees
Labels
No labels