オブジェクトストレージのURLにファイル名を含めるのを廃止

This commit is contained in:
syuilo 2018-10-16 20:14:06 +09:00
parent feef4a933e
commit cfbb6e8092
No known key found for this signature in database
GPG Key ID: BDC4C49D06AB9D69
1 changed files with 4 additions and 6 deletions

View File

@ -37,10 +37,8 @@ async function save(path: string, name: string, type: string, hash: string, size
if (config.drive && config.drive.storage == 'minio') { if (config.drive && config.drive.storage == 'minio') {
const minio = new Minio.Client(config.drive.config); const minio = new Minio.Client(config.drive.config);
const keyDir = `${config.drive.prefix}/${uuid.v4()}`; const key = `${config.drive.prefix}/${uuid.v4()}`;
const key = `${keyDir}/${name}`; const thumbnailKey = `${config.drive.prefix}/${uuid.v4()}`;
const thumbnailKeyDir = `${config.drive.prefix}/${uuid.v4()}`;
const thumbnailKey = `${thumbnailKeyDir}/${name}.thumbnail.jpg`;
const baseUrl = config.drive.baseUrl 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 }`; || `${ config.drive.config.useSSL ? 'https' : 'http' }://${ config.drive.config.endPoint }${ config.drive.config.port ? `:${config.drive.config.port}` : '' }/${ config.drive.bucket }`;
@ -64,8 +62,8 @@ async function save(path: string, name: string, type: string, hash: string, size
key: key, key: key,
thumbnailKey: thumbnailKey thumbnailKey: thumbnailKey
}, },
url: `${ baseUrl }/${ keyDir }/${ encodeURIComponent(name) }`, url: `${ baseUrl }/${ key }`,
thumbnailUrl: thumbnail ? `${ baseUrl }/${ thumbnailKeyDir }/${ encodeURIComponent(name) }.thumbnail.jpg` : null thumbnailUrl: thumbnail ? `${ baseUrl }/${ thumbnailKey }` : null
}); });
const file = await DriveFile.insert({ const file = await DriveFile.insert({