Browse Source

perf: 修复录像在线播放问题

pull/12561/head
Eric 10 months ago committed by Bryan
parent
commit
ae68241812
  1. 14
      apps/jumpserver/rewriting/storage/servers.py
  2. 4
      apps/jumpserver/settings/base.py

14
apps/jumpserver/rewriting/storage/servers.py

@ -0,0 +1,14 @@
from private_storage.servers import NginxXAccelRedirectServer, DjangoServer
class StaticFileServer(object):
@staticmethod
def serve(private_file):
full_path = private_file.full_path
# todo: gzip 文件录像 nginx 处理后,浏览器无法正常解析内容
# 造成在线播放失败,暂时仅使用 nginx 处理 mp4 录像文件
if full_path.endswith('.mp4'):
return NginxXAccelRedirectServer.serve(private_file)
else:
return DjangoServer.serve(private_file)

4
apps/jumpserver/settings/base.py

@ -319,9 +319,7 @@ MEDIA_ROOT = os.path.join(PROJECT_DIR, 'data', 'media').replace('\\', '/') + '/'
PRIVATE_STORAGE_ROOT = MEDIA_ROOT PRIVATE_STORAGE_ROOT = MEDIA_ROOT
PRIVATE_STORAGE_AUTH_FUNCTION = 'jumpserver.rewriting.storage.permissions.allow_access' PRIVATE_STORAGE_AUTH_FUNCTION = 'jumpserver.rewriting.storage.permissions.allow_access'
PRIVATE_STORAGE_INTERNAL_URL = '/private-media/' PRIVATE_STORAGE_INTERNAL_URL = '/private-media/'
PRIVATE_STORAGE_SERVER = 'nginx' PRIVATE_STORAGE_SERVER = 'jumpserver.rewriting.storage.servers.StaticFileServer'
if DEBUG_DEV:
PRIVATE_STORAGE_SERVER = 'django'
# Use django-bootstrap-form to format template, input max width arg # Use django-bootstrap-form to format template, input max width arg

Loading…
Cancel
Save