Files

27 lines
885 B
Lua
Raw Permalink Normal View History

-- 本地测试命令
-- 没有verify需要的header curl -v 'http://admin.localhost:8088/api/ngx/image/check/fd7a7ee5-afbe-4b1b-92c1-f7009e85437297
-- 带有verify需要的header
2022-03-08 21:59:25 +08:00
-- https://stackoverflow.com/questions/4990990/check-if-a-file-exists-with-lua
local http = require "resty.http"
local verify = require('lib.jwt_verify')
local httpc = http:new()
local authHeader = ngx.req.get_headers().Authorization
local sudoerToken = ngx.req.get_headers().HtySudoerToken
verify(httpc, authHeader, sudoerToken)
2022-03-08 21:59:25 +08:00
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
2023-07-28 03:06:30 +08:00
local fullpath = file_dir .. "/" .. file_to_check;
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))