@@ -18,7 +18,7 @@ import {
1818 ConflictException ,
1919 Injectable ,
2020 NotFoundException ,
21- OnModuleInit ,
21+ OnModuleInit , UnsupportedMediaTypeException ,
2222} from '@nestjs/common' ;
2323import { InjectRepository } from '@nestjs/typeorm' ;
2424import jwt from 'jsonwebtoken' ;
@@ -519,9 +519,9 @@ export class FileService implements OnModuleInit {
519519
520520 return await externalMinio . presignedUrl (
521521 'GET' ,
522- file . type === FileType . MCAP
523- ? env . MINIO_MCAP_BUCKET_NAME
524- : env . MINIO_BAG_BUCKET_NAME ,
522+ file . type === FileType . BAG
523+ ? env . MINIO_BAG_BUCKET_NAME
524+ : env . MINIO_MCAP_BUCKET_NAME ,
525525 file . uuid , // we use the uuid as the filename in Minio
526526 expires ? 4 * 60 * 60 : 604_800 , // 604800 seconds = 1 week
527527 {
@@ -792,15 +792,26 @@ export class FileService implements OnModuleInit {
792792
793793 logger . debug ( `Creating temporary access for file: ${ filename } ` ) ;
794794
795- // verify that file has ending .bag or .mcap
796- if ( ! filename . endsWith ( '.bag' ) && ! filename . endsWith ( '.mcap' ) ) {
795+ const fileExtensionToFileTypeMap : ReadonlyMap < string , FileType > = new Map ( [
796+ [ '.bag' , FileType . BAG ] ,
797+ [ '.mcap' , FileType . MCAP ] ,
798+ [ '.yaml' , FileType . YAML ] ,
799+ [ '.svo2' , FileType . SVO2 ] ,
800+ [ '.tum' , FileType . TUM ] ,
801+ [ '.db3' , FileType . DB3 ] ,
802+ ] ) ;
803+
804+ const supported_file_endings = [ ...fileExtensionToFileTypeMap . keys ( ) ] ;
805+
806+ if ( ! supported_file_endings . some ( ( ending ) => filename . endsWith ( ending ) ) ) {
797807 emptyCredentials . error = 'Invalid file ending' ;
798808 return emptyCredentials ;
799809 }
800810
801- const fileType : FileType = filename . endsWith ( '.bag' )
802- ? FileType . BAG
803- : FileType . MCAP ;
811+ const matchingFileType = supported_file_endings . find ( ending => filename . endsWith ( ending ) ) ;
812+ if ( matchingFileType === undefined ) throw new UnsupportedMediaTypeException ( ) ;
813+ const fileType : FileType | undefined = fileExtensionToFileTypeMap . get ( matchingFileType ) ;
814+ if ( fileType === undefined ) throw new UnsupportedMediaTypeException ( ) ;
804815
805816 // check if file already exists
806817 const existingFile = await this . fileRepository . exists ( {
0 commit comments