Django 媒体,mp4 服务
Django Media, mp4 serving
我现在正在做一个 Django 项目。
我可以轻松地提供媒体文件,但是当我尝试从媒体文件夹中获取视频时,出现以下响应。
HTTP 响应代码为:206 部分内容(来自磁盘缓存)
并且控制台日志是
resource interpreted as document but transferred with mime type video/mp4
有谁知道我如何解决这个问题?
这很可能是因为您提供的内容带有 [=10=] header,例如 text/html
或 text/plain
。您需要修复您的 Web 服务器配置,以便为 mp4 发送正确的 Content-Type
header,即 video/mp4
.
对于开发服务器,如果您使用的是 django.contrib.staticfiles.views.serve
,则 there is this note in the documentation:
To guess the served files’ content types, this view relies on the mimetypes
module from the Python standard library, which itself relies on the underlying platform’s map files. If you find that this view doesn’t return proper content types for certain files, it is most likely that the platform’s map files need to be updated. This can be achieved, for example, by installing or updating the mailcap
package on a Red Hat distribution, or mime-support
on a Debian distribution.
我现在正在做一个 Django 项目。
我可以轻松地提供媒体文件,但是当我尝试从媒体文件夹中获取视频时,出现以下响应。
HTTP 响应代码为:206 部分内容(来自磁盘缓存)
并且控制台日志是
resource interpreted as document but transferred with mime type video/mp4
有谁知道我如何解决这个问题?
这很可能是因为您提供的内容带有 [=10=] header,例如 text/html
或 text/plain
。您需要修复您的 Web 服务器配置,以便为 mp4 发送正确的 Content-Type
header,即 video/mp4
.
对于开发服务器,如果您使用的是 django.contrib.staticfiles.views.serve
,则 there is this note in the documentation:
To guess the served files’ content types, this view relies on the
mimetypes
module from the Python standard library, which itself relies on the underlying platform’s map files. If you find that this view doesn’t return proper content types for certain files, it is most likely that the platform’s map files need to be updated. This can be achieved, for example, by installing or updating themailcap
package on a Red Hat distribution, ormime-support
on a Debian distribution.