ドライブファイルURL生成などの修正 (#5671)

* Fix: リモートプロキシ時にサムネイルのContent-Typeがおかしい

* fix drive
This commit is contained in:
MeiMei
2020-01-02 02:45:05 +09:00
committed by syuilo
parent b0bb5d8dfc
commit 78ef0a9929
5 changed files with 8 additions and 58 deletions

View File

@ -39,25 +39,13 @@ export class DriveFileRepository extends Repository<DriveFile> {
const key = thumbnail ? file.thumbnailAccessKey : file.webpublicAccessKey;
if (key && !key.match('/')) { // 古いものはここにオブジェクトストレージキーが入ってるので除外
let ext = '';
if (file.name) {
[ext] = (file.name.match(/\.(\w+)$/) || ['']);
}
if (ext === '') {
if (file.type === 'image/jpeg') ext = '.jpg';
if (file.type === 'image/png') ext = '.png';
if (file.type === 'image/webp') ext = '.webp';
if (file.type === 'image/apng') ext = '.apng';
if (file.type === 'image/vnd.mozilla.apng') ext = '.apng';
}
return `/files/${key}/${key}${ext}`;
return `/files/${key}`;
}
}
return thumbnail ? (file.thumbnailUrl || file.webpublicUrl || null) : (file.webpublicUrl || file.url);
const isImage = file.type && ['image/png', 'image/apng', 'image/gif', 'image/jpeg', 'image/webp', 'image/svg+xml'].includes(file.type);
return thumbnail ? (file.thumbnailUrl || (isImage ? (file.webpublicUrl || file.url) : null)) : (file.webpublicUrl || file.url);
}
public async clacDriveUsageOf(user: User['id'] | User): Promise<number> {