1
0
Fork 0
mirror of https://github.com/paricafe/misskey.git synced 2025-03-05 07:02:09 -06:00
paricafe/src/misc/detect-url-mime.ts

16 lines
371 B
TypeScript
Raw Normal View History

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();
}
}