fix: memory leak on file web stream fix

This commit is contained in:
2024-03-16 21:29:29 +07:00
parent cc66501d43
commit b7c1ceb2b3
9 changed files with 148 additions and 102 deletions
+16
View File
@@ -1,3 +1,7 @@
import { Mime } from "mime/lite";
import standardTypes from "mime/types/standard.js";
import otherTypes from "mime/types/other.js";
export const formatBytes = (bytes: number) => {
const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
if (bytes === 0) return "n/a";
@@ -13,3 +17,15 @@ export const secondsToTime = (seconds: number) => {
// const s = Math.floor(seconds % 60);
return `${d}d ${h}h ${m}m`;
};
export const mime = new Mime(standardTypes, otherTypes);
mime.define(
{
"video/webm": ["mkv"],
},
true
);
export const getMimeType = (path: string) => {
return mime.getType(path) || "application/octet-stream";
};