From d81bc3cd212dbea309ce1ff2e5c9083ba943334d Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 16 Nov 2017 23:05:12 +0900 Subject: [PATCH] Fix thumbnail --- src/file/assets/thumbnail-not-available.png | Bin 0 -> 8822 bytes src/file/server.ts | 11 +++++++++++ 2 files changed, 11 insertions(+) create mode 100644 src/file/assets/thumbnail-not-available.png diff --git a/src/file/assets/thumbnail-not-available.png b/src/file/assets/thumbnail-not-available.png new file mode 100644 index 0000000000000000000000000000000000000000..f960ce4d004287e199e543ac1f6deb33bc088488 GIT binary patch literal 8822 zcmeHthgTEZxBp4#9hD-T3n(HA2+~VHE}&9^pn!Bi1nJU32_&M3Qmprb7t?)o;iDePT4arEG;TQjvId(+zxkMpEh^<)lkdaufD4S$U^$$mBE%XQToLfD{7NzG8_l?Wl`|Q z=ZK!D+CRS2C_LyiMxbv61(I?Q@K+iD*KYzKa}I#NPXlm+4WQrs-|hd--7@6B+%G(*>W(0F_IM~`7 zf-aO$ue`=BnYnYV-PhB$^aZ@(LUPl3aM=+c&Hr2vG`P<5v5Ph`Ih%4IaKN83p;G3B$S0EpMb zU9DvWg1I?LJQN|{R_WZo*wFOkzY}pxG|LDR?#rxuSD1`X}4RM)SAIO|CdkhHIK()HeszMj+kV6OtEl#w*_uL>{T%jsFnHBBc!-*#P z&BSz&gC1=w5vR?wMp@VGF74N?wP3S%HC9m2@g6VW?9#4?)`?~C^S3o37_>$ zM^YxocARlD?*2kv-yd)EV%R$k!O)$Jj%gEQn`*CpH(B(O3Z&oavs6spjuVWjnHJxl z!SaVuHXeR-*s0;Py0PwFuFOUxMb_&IQ}11e^gB{Ou`^AOhTB2dKS-6}vDx@t_G@Zr zW-~kEYu9Nz3vwHqk``;Lqs0YT zF3jQT``Rf_7goG|7_2dcy?J+Fn1XkI$LG|(Pfb9Dk(qn!_8nZ0G}5Z{J`bT_FY0j~ z>!F=bF^aa^H@Hkn!c@5*6m=>jrOp4m7&#Fh4~kVs4Tdkr{Ct1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-m7YVu!54z+f1>w5x^LY(R z7I_SNCOr@~r_PB{D3r8Aqaw`ljsNZ8tb>*-T%MdS=RM3p4D*Vo{-cn{zkRHh2p`Ai3xv!#NkicN-Je8KZ zw;O#-SRvmg?G3MW5o4%16z;Fx3Ws9x84jCmM@v}p`m8MBo7|y8Xt`lbe-=-5PV7C_ znOcHDi%>NZ4E5EFheb1iEn=|u4{wvDt?8}vgjcIA^tEV6v~b{~DDl8nyprnwq!h^i gp5GeMsH7Gei=m882+5h_0iYi@j4b{vzvdeIU-zw*0RR91 literal 0 HcmV?d00001 diff --git a/src/file/server.ts b/src/file/server.ts index fa03fb777..844b3d736 100644 --- a/src/file/server.ts +++ b/src/file/server.ts @@ -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; })();