fix
This commit is contained in:
@@ -18,7 +18,6 @@ server {
|
|||||||
set $upyun_password "NyJ51zRwFApY9Wo9EHJMrb8GI9YtvpVN";
|
set $upyun_password "NyJ51zRwFApY9Wo9EHJMrb8GI9YtvpVN";
|
||||||
set $upyun_bucket "alchemy";
|
set $upyun_bucket "alchemy";
|
||||||
set $upyun_directory "music-room";
|
set $upyun_directory "music-room";
|
||||||
set $upyun_cdn "https://upyun.alchemy-studio.cn/";
|
|
||||||
set $upyun_domain "https://upyun.alchemy-studio.cn";
|
set $upyun_domain "https://upyun.alchemy-studio.cn";
|
||||||
set $wx_domain "wx.alchemy-studio.cn";
|
set $wx_domain "wx.alchemy-studio.cn";
|
||||||
set $upt_secret "0D32E581A445404FA4C306709724FA07";
|
set $upt_secret "0D32E581A445404FA4C306709724FA07";
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ server {
|
|||||||
set $upyun_password "NyJ51zRwFApY9Wo9EHJMrb8GI9YtvpVN";
|
set $upyun_password "NyJ51zRwFApY9Wo9EHJMrb8GI9YtvpVN";
|
||||||
set $upyun_bucket "moicen";
|
set $upyun_bucket "moicen";
|
||||||
set $upyun_directory "music-room";
|
set $upyun_directory "music-room";
|
||||||
set $upyun_cdn "https://upyun.dev.moicen.com/";
|
|
||||||
set $upyun_domain "https://upyun.alchemy-studio.cn";
|
set $upyun_domain "https://upyun.alchemy-studio.cn";
|
||||||
set $wx_domain "dev.wx.moicen.com";
|
set $wx_domain "dev.wx.moicen.com";
|
||||||
set $upt_secret "0D32E581A445404FA4C306709724FA07";
|
set $upt_secret "0D32E581A445404FA4C306709724FA07";
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ server {
|
|||||||
set $upyun_password "NyJ51zRwFApY9Wo9EHJMrb8GI9YtvpVN";
|
set $upyun_password "NyJ51zRwFApY9Wo9EHJMrb8GI9YtvpVN";
|
||||||
set $upyun_bucket "moicen";
|
set $upyun_bucket "moicen";
|
||||||
set $upyun_directory "music-room";
|
set $upyun_directory "music-room";
|
||||||
set $upyun_cdn "https://upyun.dev.moicen.com/";
|
|
||||||
set $upyun_domain "https://upyun.alchemy-studio.cn";
|
set $upyun_domain "https://upyun.alchemy-studio.cn";
|
||||||
set $wx_domain "dev.wx.moicen.com";
|
set $wx_domain "dev.wx.moicen.com";
|
||||||
set $upt_secret "0D32E581A445404FA4C306709724FA07";
|
set $upt_secret "0D32E581A445404FA4C306709724FA07";
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ package.path = package.path .. ';<SCRIPT_PATH>/?.lua';
|
|||||||
|
|
||||||
local _M = {}
|
local _M = {}
|
||||||
|
|
||||||
function _M.upyun_download(httpc, Upt, pl, uri)
|
function _M.upyun_download(httpc, cjson, Upt, pl, uri)
|
||||||
|
|
||||||
ngx.log(ngx.INFO, "UPYUN DOWNLOAD : URI -> " .. uri)
|
ngx.log(ngx.INFO, "UPYUN DOWNLOAD : URI -> " .. uri)
|
||||||
|
|
||||||
@@ -22,6 +22,30 @@ function _M.upyun_download(httpc, Upt, pl, uri)
|
|||||||
method = "GET",
|
method = "GET",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ngx.log(ngx.INFO, "RESP -> ", pl.write(resp))
|
||||||
|
if no_exception == true then
|
||||||
|
if 200 ~= resp.status then
|
||||||
|
ngx.log(ngx.ERR, "UPYUN DOWNLOAD *FAILED*", pl.write(resp_err))
|
||||||
|
ngx.status = resp.status
|
||||||
|
ngx.say(pl.write(resp_err))
|
||||||
|
ngx.exit(resp.status)
|
||||||
|
else
|
||||||
|
ngx.log(ngx.ERR, "RESP IS OK -> ", pl.write(resp.body))
|
||||||
|
-- return cjson.decode(resp.body).d
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if resp == nil then
|
||||||
|
resp = ""
|
||||||
|
end
|
||||||
|
ngx.log(ngx.ERR, "FAILED TO CONNECT TO *UPYUN*: httpc throws runtime error, please check log. / ", pl.write(resp))
|
||||||
|
-- 必须先设置ngx.status,否则ngx.say之后就直接被设置为200了,不会再被exit设为401
|
||||||
|
-- https://github.com/openresty/lua-resty-redis/issues/15
|
||||||
|
ngx.status = 401
|
||||||
|
ngx.say(cjson.encode({r = false, d = "UpyunDownloadErr"}))
|
||||||
|
ngx.exit(401)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- TODO: send resp.body to Flask API (ai-api) -> convert_mxml_to_xml() -> XML string
|
-- TODO: send resp.body to Flask API (ai-api) -> convert_mxml_to_xml() -> XML string
|
||||||
-- local xml = ai-api.convert_mxml_to_xml(resp.body)
|
-- local xml = ai-api.convert_mxml_to_xml(resp.body)
|
||||||
-- ngx.log(xml)
|
-- ngx.log(xml)
|
||||||
|
|||||||
@@ -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_cdn .. 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
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ package.path = package.path .. ';<SCRIPT_PATH>/?.lua';
|
|||||||
|
|
||||||
local pl = require "pl.pretty"
|
local pl = require "pl.pretty"
|
||||||
local http = require 'resty.http'
|
local http = require 'resty.http'
|
||||||
|
local cjson = require "cjson"
|
||||||
local yun_download = require("lib.upyun_download")
|
local yun_download = require("lib.upyun_download")
|
||||||
local Upt = require("lib.upt")
|
local Upt = require("lib.upt")
|
||||||
|
|
||||||
@@ -16,7 +17,7 @@ local function upyun_download_file()
|
|||||||
|
|
||||||
local uri = ngx.unescape_uri(ngx.var.arg_uri)
|
local uri = ngx.unescape_uri(ngx.var.arg_uri)
|
||||||
ngx.log(ngx.INFO, "REQUEST UPYUN DOWNLOAD : URI -> " .. uri)
|
ngx.log(ngx.INFO, "REQUEST UPYUN DOWNLOAD : URI -> " .. uri)
|
||||||
yun_download.upyun_download(httpc, Upt, pl, uri)
|
yun_download.upyun_download(httpc, cjson, Upt, pl, uri)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user