Skip to content

Commit

Permalink
Added mimetype 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
imneonizer committed Dec 31, 2020
1 parent 48f1bd6 commit b4f8ba6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions api/endpoints/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import re
import base64
import hashlib
import mimetypes

class SendFileByToken(Resource):
def get(self):
Expand Down Expand Up @@ -145,8 +146,8 @@ def send_file(self, path, stream=False):
byte2 = int(groups[1])

chunk, start, length, file_size = self.get_chunk(path, byte1, byte2)
resp = Response(chunk, 206, mimetype='video/mp4',
content_type='video/mp4', direct_passthrough=True)
resp = Response(chunk, 206, mimetype=mimetypes.guess_type(path),
content_type=mimetypes.guess_type(path), direct_passthrough=True)
resp.headers.add('Content-Range', 'bytes {0}-{1}/{2}'.format(start, start + length - 1, file_size))
return resp

Expand Down

0 comments on commit b4f8ba6

Please sign in to comment.