mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 23:24:46 -04:00
fix(media-controller): throw if no file was uploaded
Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
9d8d5e8d55
commit
b311265762
2 changed files with 13 additions and 2 deletions
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import {
|
||||
BadRequestException,
|
||||
Controller,
|
||||
Delete,
|
||||
Param,
|
||||
|
@ -73,12 +74,15 @@ export class MediaController {
|
|||
500,
|
||||
)
|
||||
async uploadMedia(
|
||||
@UploadedFile() file: MulterFile,
|
||||
@UploadedFile() file: MulterFile | undefined,
|
||||
@RequestNote() note: Note,
|
||||
@RequestUser() user: User,
|
||||
): Promise<MediaUploadDto> {
|
||||
if (file === undefined) {
|
||||
throw new BadRequestException('Request does not contain a file');
|
||||
}
|
||||
this.logger.debug(
|
||||
`Recieved filename '${file.originalname}' for note '${note.id}' from user '${user.username}'`,
|
||||
`Received filename '${file.originalname}' for note '${note.id}' from user '${user.username}'`,
|
||||
'uploadMedia',
|
||||
);
|
||||
const upload = await this.mediaService.saveFile(file.buffer, user, note);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue