-- retrieve the content of a URL local http = require "resty.http" local pl = require "pl.pretty" --local Upt = require "lib/upt" local httpc = http:new() local uri = "/music-room/17c832cb-bc6b-41f7-96cd-190b7fe4a3d7.jpeg" local secret = "0D32E581A445404FA4C306709724FA07" local duration = "3600" local etime = os.time() + duration local sign = ngx.md5(secret .. '&' .. etime .. '&' .. uri) --ngx.log(ngx.INFO, 'sign...' .. sign .. ' etime..' .. etime) ngx.say('sign...' .. sign .. ' etime..' .. etime) local _upt = string.sub(sign, 13, 13 + 7) .. etime --local _upt = Upt.upt() ngx.say("UPT -> ", _upt) local remote_url = "https://upyun.alchemy-studio.cn/music-room/17c832cb-bc6b-41f7-96cd-190b7fe4a3d7.jpeg?_upt=" .. _upt local no_exception, resp, resp_err = pcall(httpc.request_uri, httpc, remote_url, { ssl_verify = false, -- 设置参数 ssl_verify 为false 不校验ssl证书 method = "GET", }) --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) --ngx.say(xml) --ngx.say("RESP -> ", pl.write(resp)) ------ save the content to a file --local f = assert(io.open('test.jpg', 'wb')) -- open in "binary" mode --f:write(resp.body) ---- --f:close()