Files
resty_functions/scripts/check_file.lua
T

14 lines
460 B
Lua
Raw Normal View History

2022-03-08 21:59:25 +08:00
-- https://stackoverflow.com/questions/4990990/check-if-a-file-exists-with-lua
local function file_exists(name)
local f = io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
end
local file_to_check = string.match(ngx.var.request_uri, ".*/(.*)")
local file_dir = ngx.var.tmp_file_dir
2022-08-22 23:59:02 +08:00
local fullpath = file_dir .. "/" .. file_to_check .. ".png";
2022-03-09 01:57:15 +08:00
ngx.log(ngx.INFO, "FILE TO CHECK -> ", fullpath)
2022-03-08 21:59:25 +08:00
ngx.say(file_exists(fullpath))