From 9703ba53405b2f355c6e0317f714d82ff3d4dee3 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Sun, 12 Jan 2020 16:40:58 +0900 Subject: ファイルと画像認識処理の改善 (#5690) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * dimensions制限とリファクタ * comment * 不要な変更削除 * use fromFile など * Add probe-image-size.d.ts * えーCRLFで作るなよ… * Update src/@types/probe-image-size.d.ts Co-Authored-By: Acid Chicken (硫酸鶏) * fix d.ts * Update src/@types/probe-image-size.d.ts Co-Authored-By: Acid Chicken (硫酸鶏) * Update src/@types/probe-image-size.d.ts Co-Authored-By: Acid Chicken (硫酸鶏) * fix Co-authored-by: Acid Chicken (硫酸鶏) --- src/server/file/send-drive-file.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/server/file') diff --git a/src/server/file/send-drive-file.ts b/src/server/file/send-drive-file.ts index 2283435794..0b14378589 100644 --- a/src/server/file/send-drive-file.ts +++ b/src/server/file/send-drive-file.ts @@ -8,7 +8,7 @@ import { contentDisposition } from '../../misc/content-disposition'; import { DriveFiles } from '../../models'; import { InternalStorage } from '../../services/drive/internal-storage'; import { downloadUrl } from '../../misc/donwload-url'; -import { detectMine } from '../../misc/detect-mine'; +import { detectType } from '../../misc/get-file-info'; import { convertToJpeg, convertToPng } from '../../services/drive/image-processor'; import { GenerateVideoThumbnail } from '../../services/drive/generate-video-thumbnail'; @@ -52,15 +52,15 @@ export default async function(ctx: Koa.Context) { try { await downloadUrl(file.uri, path); - const [type, ext] = await detectMine(path); + const { mime, ext } = await detectType(path); const convertFile = async () => { if (isThumbnail) { - if (['image/jpeg', 'image/webp'].includes(type)) { + if (['image/jpeg', 'image/webp'].includes(mime)) { return await convertToJpeg(path, 498, 280); - } else if (['image/png'].includes(type)) { + } else if (['image/png'].includes(mime)) { return await convertToPng(path, 498, 280); - } else if (type.startsWith('video/')) { + } else if (mime.startsWith('video/')) { return await GenerateVideoThumbnail(path); } } @@ -68,7 +68,7 @@ export default async function(ctx: Koa.Context) { return { data: fs.readFileSync(path), ext, - type, + type: mime, }; }; -- cgit v1.2.3-freya