We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ee77282 commit 288627cCopy full SHA for 288627c
app/streamer/index.js
@@ -4,6 +4,8 @@ import path from 'path';
4
import portfinder from 'portfinder';
5
import fs from 'mz/fs';
6
import fetch from 'node-fetch';
7
+import mime from 'mime';
8
+import Url from 'url';
9
10
class Streamer {
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)
29
.then((zip) => this.get(zip, req.params.asset))
- .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
+ })
37
.catch((err) => {
38
console.error(err);
39
res.statusMessage = 'File not found';
0 commit comments