2022-02-27 03:07:39 +01:00
|
|
|
import { createTemp } from './create-temp.js';
|
|
|
|
import { downloadUrl } from './download-url.js';
|
|
|
|
import { detectType } from './get-file-info.js';
|
2019-03-20 20:50:44 +01:00
|
|
|
|
2020-01-12 08:40:58 +01:00
|
|
|
export async function detectUrlMime(url: string) {
|
2019-03-20 20:50:44 +01:00
|
|
|
const [path, cleanup] = await createTemp();
|
|
|
|
|
|
|
|
try {
|
|
|
|
await downloadUrl(url, path);
|
2020-01-12 08:40:58 +01:00
|
|
|
const { mime } = await detectType(path);
|
|
|
|
return mime;
|
2019-03-20 20:50:44 +01:00
|
|
|
} finally {
|
|
|
|
cleanup();
|
|
|
|
}
|
|
|
|
}
|