start with streamer

This commit is contained in:
Jurgis Sakalauskas
2022-12-14 15:55:50 +02:00
parent d999897068
commit df6bf9465f
12 changed files with 263 additions and 38 deletions
+32
View File
@@ -0,0 +1,32 @@
import { Injectable } from '@nestjs/common';
import { extname } from 'path';
@Injectable()
export class MimeService {
private mimeNames = {
'.css': 'text/css',
'.html': 'text/html',
'.js': 'application/javascript',
'.mp3': 'audio/mpeg',
'.mp4': 'video/mp4',
'.ogg': 'application/ogg',
'.ogv': 'video/ogg',
'.oga': 'audio/ogg',
'.txt': 'text/plain',
'.wav': 'audio/x-wav',
'.webm': 'video/webm',
'.mkv': 'video/x-matroska',
'.m3u': 'application/vnd.apple.mpegurl',
'.ts': 'video/MP2T',
'.json': 'application/json',
'.avi': 'video/x-msvideo',
};
getMime(filePath: string): string {
return this.getMimeNameFromExt(extname(filePath));
}
private getMimeNameFromExt(ext): string {
return this.mimeNames[ext.toLowerCase()] ?? 'application/octet-stream';
}
}