m
This commit is contained in:
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
"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
|
||||
Reference in New Issue
Block a user