25 lines
881 B
JavaScript
25 lines
881 B
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.COSHelp = void 0;
|
|
const COS = require("cos-nodejs-sdk-v5");
|
|
const app_env_1 = require("../../../app.env");
|
|
const cos = new COS({
|
|
SecretId: app_env_1.AppEnv.COS_SECRET_ID,
|
|
SecretKey: app_env_1.AppEnv.COS_SECRET_KEY,
|
|
});
|
|
exports.COSHelp = {
|
|
upload(file) {
|
|
const timestamp = Date.now();
|
|
const randomStr = Math.random().toString(36).substring(2, 8);
|
|
const fileExtension = file.originalname.split('.').pop();
|
|
const key = `images/${timestamp}-${randomStr}.${fileExtension}`;
|
|
return cos.uploadFile({
|
|
Bucket: app_env_1.AppEnv.COS_BUCKET,
|
|
Region: app_env_1.AppEnv.COS_REGION,
|
|
Key: key,
|
|
FilePath: file.path,
|
|
SliceSize: 1024 * 1024 * 5,
|
|
});
|
|
},
|
|
};
|
|
//# sourceMappingURL=cos_help.js.map
|