Files
CJGIS_UAVPatrol/server/api/upload/token/function.js
❀ » Cato Sweeney. ❀ » Console@the.bb bb46cb3bcc *
2025-11-27 16:14:04 +08:00

43 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// ==========================================================================
// 所属模块Upload/Token
// 生成日期2024-02-08 17:09:21 +0800 CST
// 生成路径: upload/token/function.js
// 生成人xScript_Engine
// 数据表sys_files - 文件上传(又拍云)
// ==========================================================================
response.headers.add('X-Script-Version', 'upload-1.0');
function main() {
// 验证用户权限
'use api/user/acl/excerpt.js'
let content_md5 = payload.get().path.split("/").pop()
const sql = `SELECT * FROM sys_files WHERE file_hash =? LIMIT 1;`;
let res = SQL.query('system_sql', sql, content_md5);
if (res.length > 0) {
res = res[0]
okMsg({
path: res.file_path,
type: res.file_type,
size: res.file_size,
})
}
let password = crypto.hash.md5("v5JuNat8fget0184tFTTRH2Nyap35DiS").toHEX.encoding().toString();
// console.log(password);
let method = `PUT`
let file = `/${os.getEnv('BUCKET_NAME')}/${ex.suid().base58()}`
let now = new Date(Date.now()).toUTCString();
let digest = crypto.hash.hmac.sha1(password, `${method}&${file}&${now}&${content_md5}`).toBase64.encoding().toString();
// console.log(digest);
return okMsg({
file: file,
domain: 'cdn.p-q.co',
token: `UPYUN xmagic:${digest}`,
content_md5: content_md5
});
}