forked from FoundKeyGang/FoundKey
Fix thumbnail
This commit is contained in:
parent
a757960c41
commit
d81bc3cd21
2 changed files with 11 additions and 0 deletions
BIN
src/file/assets/thumbnail-not-available.png
Normal file
BIN
src/file/assets/thumbnail-not-available.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
|
@ -50,11 +50,22 @@ interface ISend {
|
|||
|
||||
function thumbnail(data: stream.Readable, type: string, resize: number): ISend {
|
||||
const readable: stream.Readable = (() => {
|
||||
// 画像ではない場合
|
||||
if (!/^image\/.*$/.test(type)) {
|
||||
// 使わないことにしたストリームはしっかり取り壊しておく
|
||||
data.destroy();
|
||||
return fs.createReadStream(`${__dirname}/assets/not-an-image.png`);
|
||||
}
|
||||
|
||||
const imageType = type.split('/')[1];
|
||||
|
||||
// 画像でもPNGかJPEGでないならダメ
|
||||
if (imageType != 'png' && imageType != 'jpeg') {
|
||||
// 使わないことにしたストリームはしっかり取り壊しておく
|
||||
data.destroy();
|
||||
return fs.createReadStream(`${__dirname}/assets/thumbnail-not-available.png`);
|
||||
}
|
||||
|
||||
return data;
|
||||
})();
|
||||
|
||||
|
|
Loading…
Reference in a new issue