2019-03-20 14:50:44 -05:00
|
|
|
import { createTemp } from './create-temp';
|
|
|
|
import { downloadUrl } from './donwload-url';
|
2020-01-12 01:40:58 -06:00
|
|
|
import { detectType } from './get-file-info';
|
2019-03-20 14:50:44 -05:00
|
|
|
|
2020-01-12 01:40:58 -06:00
|
|
|
export async function detectUrlMime(url: string) {
|
2019-03-20 14:50:44 -05:00
|
|
|
const [path, cleanup] = await createTemp();
|
|
|
|
|
|
|
|
try {
|
|
|
|
await downloadUrl(url, path);
|
2020-01-12 01:40:58 -06:00
|
|
|
const { mime } = await detectType(path);
|
|
|
|
return mime;
|
2019-03-20 14:50:44 -05:00
|
|
|
} finally {
|
|
|
|
cleanup();
|
|
|
|
}
|
|
|
|
}
|