Skip to content

Commit

Permalink
Fix mime type for video downloads
Browse files Browse the repository at this point in the history
Make videos have mime type specific to the respective format instead of video/mpeg
Addresses:
- #740
- #775
  • Loading branch information
Mrnt committed Feb 4, 2018
1 parent e35a6cf commit a765b70
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions motioneye/handlers.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import hashlib
import json
import logging
import mimetypes
import os
import re
import socket
Expand Down Expand Up @@ -1521,7 +1522,7 @@ def download(self, camera_id, filename):
content = mediafiles.get_media_content(camera_config, filename, 'movie')

pretty_filename = camera_config['@name'] + '_' + os.path.basename(filename)
self.set_header('Content-Type', 'video/mpeg')
self.set_header('Content-Type', mimetypes.guess_type(filename)[0] or 'video/mpeg')
self.set_header('Content-Disposition', 'attachment; filename=' + pretty_filename + ';')

self.finish(content)
Expand All @@ -1533,7 +1534,7 @@ def on_response(response=None, error=None):
'url': remote.pretty_camera_url(camera_config), 'msg': error}})

pretty_filename = os.path.basename(filename) # no camera name available w/o additional request
self.set_header('Content-Type', 'video/mpeg')
self.set_header('Content-Type', mimetypes.guess_type(filename)[0] or 'video/mpeg')
self.set_header('Content-Disposition', 'attachment; filename=' + pretty_filename + ';')

self.finish(response)
Expand Down

0 comments on commit a765b70

Please sign in to comment.