m
This commit is contained in:
+14
-12
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user