update test_upt
This commit is contained in:
@@ -1,10 +1,36 @@
|
||||
-- retrieve the content of a URL
|
||||
local http = require("socket.http")
|
||||
local body, code = http.request("https://upyun.alchemy-studio.cn/music-room/17c832cb-bc6b-41f7-96cd-190b7fe4a3d7.jpeg?_upt=e487088a1661273055")
|
||||
if not body then error(code) end
|
||||
local http = require "resty.http"
|
||||
local pl = require "pl.pretty"
|
||||
--local Upt = require "lib/upt"
|
||||
local httpc = http:new()
|
||||
|
||||
-- save the content to a file
|
||||
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",
|
||||
})
|
||||
|
||||
|
||||
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(body)
|
||||
|
||||
f:write(resp.body)
|
||||
--
|
||||
f:close()
|
||||
|
||||
Reference in New Issue
Block a user