add chek file and upload combined image verify

This commit is contained in:
XiaoLi
2022-08-31 23:34:54 +08:00
committed by 阿男
parent 3a724b822d
commit 2f0a22528c
4 changed files with 32 additions and 12 deletions
+8 -11
View File
@@ -41,6 +41,14 @@ server {
return 200; return 200;
} }
location /api/ngx/image/check {
content_by_lua_file $resty_loc/nginx/scripts/check_file.lua;
}
location /api/ngx/image/upload_combined {
content_by_lua_file $resty_loc/nginx/scripts/upload_combined_image.lua;
}
#Upload image files #Upload image files
location /api/ngx/image/upload { location /api/ngx/image/upload {
content_by_lua_file $resty_loc/nginx/scripts/old_upload.lua; content_by_lua_file $resty_loc/nginx/scripts/old_upload.lua;
@@ -57,21 +65,10 @@ server {
location /api/ngx/image/wx_upload_to_combine { location /api/ngx/image/wx_upload_to_combine {
content_by_lua_file $resty_loc/nginx/scripts/wx_upload_to_combine.lua; content_by_lua_file $resty_loc/nginx/scripts/wx_upload_to_combine.lua;
} }
#Combine image files #Combine image files
location /api/ngx/image/combine { location /api/ngx/image/combine {
content_by_lua_file $resty_loc/nginx/scripts/combine.lua; content_by_lua_file $resty_loc/nginx/scripts/combine.lua;
} }
location /api/ngx/image/check {
content_by_lua_file $resty_loc/nginx/scripts/check_file.lua;
}
location /api/ngx/image/upload_combined {
content_by_lua_file $resty_loc/nginx/scripts/upload_combined_image.lua;
}
#Audio file download #Audio file download
location /api/ngx/audio/upload { location /api/ngx/audio/upload {
content_by_lua_file $resty_loc/nginx/scripts/upload_audio.lua; content_by_lua_file $resty_loc/nginx/scripts/upload_audio.lua;
+13
View File
@@ -1,4 +1,17 @@
-- 本地测试命令
-- 没有verify需要的header curl -v 'http://admin.localhost:8088/api/ngx/image/check/fd7a7ee5-afbe-4b1b-92c1-f7009e85437297
-- 带有verify需要的header
-- https://stackoverflow.com/questions/4990990/check-if-a-file-exists-with-lua -- 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)
local function file_exists(name) local function file_exists(name)
local f = io.open(name,"r") local f = io.open(name,"r")
if f~=nil then io.close(f) return true else return false end if f~=nil then io.close(f) return true else return false end
+1 -1
View File
@@ -35,7 +35,7 @@ function upyun_upload.upload(filepath, filename)
return return
else else
ngx.status = 200 ngx.status = 200
local fullpath = ngx.var.$upyun_domain .. "/" .. directory .. "/" .. filename local fullpath = ngx.var.upyun_domain .. "/" .. directory .. "/" .. filename
ngx.log(ngx.INFO, "UPYUN URL -> ", fullpath) ngx.log(ngx.INFO, "UPYUN URL -> ", fullpath)
ngx.say(fullpath) ngx.say(fullpath)
end end
+10
View File
@@ -1,4 +1,14 @@
package.path = package.path .. ';<SCRIPT_PATH>/?.lua'; package.path = package.path .. ';<SCRIPT_PATH>/?.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)
ngx.log(ngx.INFO, 'UPLOAD COMBINED IMAGE -> start') ngx.log(ngx.INFO, 'UPLOAD COMBINED IMAGE -> start')
local upyun_upload = require("lib.upyun_upload") local upyun_upload = require("lib.upyun_upload")
ngx.log(ngx.INFO, 'UPLOAD COMBINED IMAGE -> upyun_upload loaded') ngx.log(ngx.INFO, 'UPLOAD COMBINED IMAGE -> upyun_upload loaded')