From a82b77d02e65f7a6219c8037f6efb38fe47f8f81 Mon Sep 17 00:00:00 2001 From: a158 Date: Wed, 14 Jan 2026 22:08:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=8A=E4=BC=A0=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- target/aliyun/oss.lua | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/target/aliyun/oss.lua b/target/aliyun/oss.lua index 25f3631..84a65e3 100644 --- a/target/aliyun/oss.lua +++ b/target/aliyun/oss.lua @@ -95,7 +95,53 @@ function M.upload_file(config,remote_dir,local_filepath,auto_remove) end return false,result end +function M.upload_data(config,remote_dir,data,ext) + if #data == 0 then + return false,"数据为空" + end + local filename = fw.make_software_guid().."."..ext + + local dirpath = "" + + for dir, ext_list in pairs(M.ext_dirpath) do + for _, ext_type_ext in ipairs(ext_list) do + if ext_type_ext == ext then + dirpath = dir + break + end + end + if dirpath ~= "" then + break + end + end + if dirpath == "" then + return false,"不支持的文件格式,ext: "..ext + end + + if remote_dir == nil or remote_dir == "" then + remote_dir = "" + else + remote_dir = remote_dir.."/" + end + + local cos_filepath = remote_dir .. dirpath.."/"..filename + local oss = aliyun_oss.new() + + + local result = oss:updata( + config.endpoint, + config.access_key_id, + config.access_key_secret, + config.bucket_name, + cos_filepath, + data + ) + if result == "" then + return true,cos_filepath + end + return false,result +end return M \ No newline at end of file