ファイルと画像認識処理の改善 (#5690)
* dimensions制限とリファクタ * comment * 不要な変更削除 * use fromFile など * Add probe-image-size.d.ts * えーCRLFで作るなよ… * Update src/@types/probe-image-size.d.ts Co-Authored-By: Acid Chicken (硫酸鶏) <root@acid-chicken.com> * fix d.ts * Update src/@types/probe-image-size.d.ts Co-Authored-By: Acid Chicken (硫酸鶏) <root@acid-chicken.com> * Update src/@types/probe-image-size.d.ts Co-Authored-By: Acid Chicken (硫酸鶏) <root@acid-chicken.com> * fix Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
This commit is contained in:
15
src/misc/detect-url-mime.ts
Normal file
15
src/misc/detect-url-mime.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { createTemp } from './create-temp';
|
||||
import { downloadUrl } from './donwload-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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user