From 704e217dbbcd30a75667670d99bb1a01eaee2442 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 16 Oct 2018 20:59:36 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=AA=E3=83=96=E3=82=B8=E3=82=A7=E3=82=AF?= =?UTF-8?q?=E3=83=88=E3=82=B9=E3=83=88=E3=83=AC=E3=83=BC=E3=82=B8=E3=81=AE?= =?UTF-8?q?URL=E3=81=AB=E6=8B=A1=E5=BC=B5=E5=AD=90=E3=82=92=E5=90=AB?= =?UTF-8?q?=E3=82=81=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/drive/add-file.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/services/drive/add-file.ts b/src/services/drive/add-file.ts index 4f637f16ee..3e689bec6a 100644 --- a/src/services/drive/add-file.ts +++ b/src/services/drive/add-file.ts @@ -37,8 +37,10 @@ async function save(path: string, name: string, type: string, hash: string, size if (config.drive && config.drive.storage == 'minio') { const minio = new Minio.Client(config.drive.config); - const key = `${config.drive.prefix}/${uuid.v4()}`; - const thumbnailKey = `${config.drive.prefix}/${uuid.v4()}`; + const [ext] = (name.match(/\.([a-zA-Z0-9_-]+)$/) || ['']); + + const key = `${config.drive.prefix}/${uuid.v4()}${ext}`; + const thumbnailKey = `${config.drive.prefix}/${uuid.v4()}.jpg`; const baseUrl = config.drive.baseUrl || `${ config.drive.config.useSSL ? 'https' : 'http' }://${ config.drive.config.endPoint }${ config.drive.config.port ? `:${config.drive.config.port}` : '' }/${ config.drive.bucket }`;