add md5 to http header
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
-- 指定模块引用目录,否则无法加载同目录下的其他文件
|
||||
--package.path = package.path .. ';/usr/local/opt/openresty/nginx/scripts/?.lua';
|
||||
--package.path = package.path .. ';/Users/liyong/Code/AlchemyStudio/resty_functions/scripts/?.lua';
|
||||
package.path = package.path .. ';<SCRIPT_PATH>/?.lua';
|
||||
|
||||
local upyun_upload = {}
|
||||
@@ -11,6 +12,8 @@ function upyun_upload.upload(filepath, filename)
|
||||
local upyun, err = Upyun:new({
|
||||
user = ngx.var.upyun_operator,
|
||||
passwd = ngx.var.upyun_password,
|
||||
--user = "moicen",
|
||||
--passwd = "NyJ51zRwFApY9Wo9EHJMrb8GI9YtvpVN",
|
||||
localFilePath = filepath
|
||||
})
|
||||
|
||||
@@ -22,6 +25,8 @@ function upyun_upload.upload(filepath, filename)
|
||||
|
||||
local bucket = ngx.var.upyun_bucket
|
||||
local directory = ngx.var.upyun_directory
|
||||
--local bucket = "huiwing"
|
||||
--local directory = "music-room"
|
||||
if not filename then
|
||||
filename = strip_path.strip_path(filepath)
|
||||
end
|
||||
@@ -32,15 +37,21 @@ function upyun_upload.upload(filepath, filename)
|
||||
local savePath = bucket .. "/" .. directory .. "/" .. filename
|
||||
ngx.log(ngx.INFO, " savePath " , savePath)
|
||||
|
||||
local info, err = upyun:upload_file(savePath, nil, nil)
|
||||
local options = {
|
||||
md5 = true
|
||||
}
|
||||
|
||||
local info, err = upyun:upload_file(savePath, nil, options)
|
||||
if not info then
|
||||
ngx.status = 502
|
||||
ngx.status = 400
|
||||
ngx.log(ngx.ERR, "failed to upload file : " .. err)
|
||||
return
|
||||
else
|
||||
ngx.status = 200
|
||||
local fullpath = ngx.var.upyun_domain .. "/" .. directory .. "/" .. filename
|
||||
--local fullpath = "https://upyun.huiwings.cn" .. "/" .. directory .. "/" .. filename
|
||||
ngx.log(ngx.INFO, "SUCCESS UPLOAD -> UPYUN URL -> ", fullpath)
|
||||
--ngx.say("SUCCESS UPLOAD -> UPYUN URL -> ", fullpath)
|
||||
ngx.say(fullpath)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user