allow audio upload
This commit is contained in:
@@ -24,14 +24,6 @@ export class UploaderService {
|
|||||||
'video/avi',
|
'video/avi',
|
||||||
'video/mov',
|
'video/mov',
|
||||||
'video/mkv',
|
'video/mkv',
|
||||||
'audio/mp3',
|
|
||||||
'audio/wav',
|
|
||||||
'audio/ogg',
|
|
||||||
'audio/webm',
|
|
||||||
'audio/m4a',
|
|
||||||
'audio/aac',
|
|
||||||
'audio/flac',
|
|
||||||
'audio/m4a',
|
|
||||||
'image/jpeg',
|
'image/jpeg',
|
||||||
'image/png',
|
'image/png',
|
||||||
'image/gif',
|
'image/gif',
|
||||||
@@ -107,12 +99,19 @@ export class UploaderService {
|
|||||||
UploaderMessage.UPLOAD_FILE_TOO_LARGE.replace('[MAX_FILE_SIZE]', this.maxFileSize.toString()),
|
UploaderMessage.UPLOAD_FILE_TOO_LARGE.replace('[MAX_FILE_SIZE]', this.maxFileSize.toString()),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!this.allowedMimeTypes.includes(file.mimetype))
|
if (!this.isAllowedMimeType(file.mimetype))
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
UploaderMessage.UPLOAD_FILE_TYPE_NOT_SUPPORTED.replace('[MIME_TYPES]', file.mimetype),
|
UploaderMessage.UPLOAD_FILE_TYPE_NOT_SUPPORTED.replace('[MIME_TYPES]', file.mimetype),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private isAllowedMimeType(mimetype: string): boolean {
|
||||||
|
if (mimetype.startsWith('audio/')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return this.allowedMimeTypes.includes(mimetype);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine file type based on mimetype
|
* Determine file type based on mimetype
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user