iceshrimp-legacy/packages/backend/src/misc/detect-url-mime.ts

16 lines
371 B
TypeScript
Raw Normal View History

2023-01-13 05:40:33 +01:00
import { createTemp } from "./create-temp.js";
import { downloadUrl } from "./download-url.js";
import { detectType } from "./get-file-info.js";
export async function detectUrlMime(url: string) {
const [path, cleanup] = await createTemp();
try {
await downloadUrl(url, path);
const { mime } = await detectType(path);
return mime;
} finally {
cleanup();
}
}