mirror of
https://github.com/khairul169/home-lab.git
synced 2026-10-02 17:13:57 +07:00
fix: memory leak on file web stream fix
This commit is contained in:
@@ -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";
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user