From 26f2ae093bcb2e9eba703e9f865c264beb04dc99 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Fri, 5 Jul 2019 17:44:23 +0900 Subject: [PATCH] =?UTF-8?q?APNG=E3=81=A7=E3=82=82MIME=20type=E3=81=AFimage?= =?UTF-8?q?/png=E3=81=AB=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=20(#?= =?UTF-8?q?5100)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * APNGでもMIME typeはimage/pngにするように * Revert "APNGでもMIME typeはimage/pngにするように" This reverts commit e579eb2bf44f526cabfa9bd4adc6b4fa84727e3b. * APNGはファイル送信時のみimage/pngにするように --- src/server/file/send-drive-file.ts | 2 +- src/services/drive/add-file.ts | 2 ++ src/services/drive/image-processor.ts | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/server/file/send-drive-file.ts b/src/server/file/send-drive-file.ts index 5da3d79eb..44e88be8a 100644 --- a/src/server/file/send-drive-file.ts +++ b/src/server/file/send-drive-file.ts @@ -42,7 +42,7 @@ export default async function(ctx: Koa.BaseContext) { ctx.set('Content-Disposition', contentDisposition('inline', `${rename(file.name, { suffix: '-thumb', extname: '.jpeg' })}`)); ctx.body = InternalStorage.read(key); } else if (isWebpublic) { - ctx.set('Content-Type', file.type); + ctx.set('Content-Type', file.type === 'image/apng' ? 'image/png' : file.type); ctx.set('Content-Disposition', contentDisposition('inline', `${rename(file.name, { suffix: '-web' })}`)); ctx.body = InternalStorage.read(key); } else { diff --git a/src/services/drive/add-file.ts b/src/services/drive/add-file.ts index e7b1e2a81..2f0d5d626 100644 --- a/src/services/drive/add-file.ts +++ b/src/services/drive/add-file.ts @@ -207,6 +207,8 @@ export async function generateAlts(path: string, type: string, generateWeb: bool * Upload to ObjectStorage */ async function upload(key: string, stream: fs.ReadStream | Buffer, type: string, filename?: string) { + if (type === 'image/apng') type = 'image/png'; + const meta = await fetchMeta(); const minio = new Minio.Client({ diff --git a/src/services/drive/image-processor.ts b/src/services/drive/image-processor.ts index 919d9ce13..4b8db0e0c 100644 --- a/src/services/drive/image-processor.ts +++ b/src/services/drive/image-processor.ts @@ -97,6 +97,6 @@ export async function convertToApng(path: string): Promise { return { data, ext: 'apng', - type: 'image/vnd.mozilla.apng' + type: 'image/apng' }; }