This commit is contained in:
qq
2026-04-21 23:57:50 +08:00
parent 0e4c3a9c11
commit ad37d9bf7e
4 changed files with 20 additions and 18 deletions
+14 -12
View File
@@ -27,11 +27,11 @@ __decorate([
__metadata("design:type", String)
], UploadVo.prototype, "url", void 0);
class CommonUploadController {
image(file, request) {
async image(file) {
try {
const result = await cos_help_1.COSHelp.upload(file);
return api_1.Api.success({
path: 'https://' + result.Location,
url: 'https://' + result.Location,
});
}
catch {
@@ -39,12 +39,15 @@ class CommonUploadController {
}
}
video(file, request) {
const host1 = request.headers['x-forwarded-host'] || request.headers.host;
const host2 = request.get('host');
const url = `${request.protocol}://${host1 || host2}/${file.path}`;
return api_1.Api.success({
url,
});
try {
const result = await cos_help_1.COSHelp.upload(file);
return api_1.Api.success({
url: 'https://' + result.Location,
});
}
catch {
return api_1.Api.error('uoload error');
}
}
}
exports.CommonUploadController = CommonUploadController;
@@ -79,10 +82,9 @@ __decorate([
}),
openapi.ApiResponse({ status: 201, type: Object }),
__param(0, (0, common_1.UploadedFile)()),
__param(1, (0, common_1.Req)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object]),
__metadata("design:returntype", void 0)
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], CommonUploadController.prototype, "image", null);
__decorate([
(0, common_1.Post)('video'),
@@ -113,7 +115,7 @@ __decorate([
},
},
}),
openapi.ApiResponse({ status: 201 }),
openapi.ApiResponse({ status: 201, type: Object }),
__param(0, (0, common_1.UploadedFile)()),
__param(1, (0, common_1.Req)()),
__metadata("design:type", Function),