File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ import path from 'path';
4
4
import portfinder from 'portfinder' ;
5
5
import fs from 'mz/fs' ;
6
6
import fetch from 'node-fetch' ;
7
+ import mime from 'mime' ;
8
+ import Url from 'url' ;
7
9
8
10
class Streamer {
9
11
constructor ( repo , port ) {
@@ -25,7 +27,13 @@ class Streamer {
25
27
this . resolveEpub ( `${ req . params . book } .epub` , req . params . url )
26
28
. then ( this . open )
27
29
. then ( ( zip ) => this . get ( zip , req . params . asset ) )
28
- . then ( ( stream ) => stream . pipe ( res ) )
30
+ . then ( ( stream ) => {
31
+ let asset = req . params . asset ;
32
+ let path = Url . parse ( asset ) . pathname || '' ;
33
+ let mimeType = mime . lookup ( path ) ;
34
+ res . contentType ( mimeType ) ;
35
+ stream . pipe ( res )
36
+ } )
29
37
. catch ( ( err ) => {
30
38
console . error ( err ) ;
31
39
res . statusMessage = 'File not found' ;
You can’t perform that action at this time.
0 commit comments