iceshrimp-161sh/packages/backend/src/misc/detect-url-mime.ts
syuilo 14148f6c4a refactoring
Resolve #7779
2021-11-12 02:02:25 +09:00

16 lines
362 B
TypeScript

import { createTemp } from './create-temp';
import { downloadUrl } from './download-url';
import { detectType } from './get-file-info';
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();
}
}