备份:修复前完整项目快照 2026-04-19

This commit is contained in:
root
2026-04-19 19:15:01 +08:00
parent 5266d7732b
commit d00f41a120
449 changed files with 89577 additions and 23251 deletions
+33
View File
@@ -0,0 +1,33 @@
// COS配置 - 香港区域
const COS = require('cos-nodejs-sdk-v5');
const cosConfig = {
SecretId: process.env.TENCENT_SECRET_ID || '',
SecretKey: process.env.TENCENT_SECRET_KEY || '',
Bucket: 'qingyuan-erp-files-1257307187',
Region: 'ap-hongkong'
};
const cos = new COS(cosConfig);
const imageFormats = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'bmp', 'svg'];
// 上传到COS
function uploadToCOS(buffer, filename, mimetype) {
return new Promise((resolve, reject) => {
cos.putObject({
Bucket: cosConfig.Bucket,
Region: cosConfig.Region,
Key: filename,
Body: buffer,
ContentType: mimetype
}, (err, data) => {
if (err) reject(err);
else {
const url = 'https://' + cosConfig.Bucket + '.cos.' + cosConfig.Region + '.myqcloud.com/' + filename;
resolve({ url, filename });
}
});
});
}
module.exports = { cos, cosConfig, uploadToCOS, imageFormats };