2013-11-28 23:55:46 +00:00
|
|
|
"""Port of django-sendfile in django-downloadview."""
|
2024-08-05 08:51:17 +00:00
|
|
|
|
2013-11-28 23:55:46 +00:00
|
|
|
from django_downloadview.views.path import PathDownloadView
|
|
|
|
|
|
|
|
|
|
|
2020-01-07 14:10:42 +00:00
|
|
|
def sendfile(
|
|
|
|
|
request,
|
|
|
|
|
filename,
|
|
|
|
|
attachment=False,
|
|
|
|
|
attachment_filename=None,
|
|
|
|
|
mimetype=None,
|
|
|
|
|
encoding=None,
|
|
|
|
|
):
|
2013-11-28 23:55:46 +00:00
|
|
|
"""Port of django-sendfile's API in django-downloadview.
|
|
|
|
|
|
|
|
|
|
Instantiates a :class:`~django_downloadview.views.path.PathDownloadView` to
|
|
|
|
|
stream the file by ``filename``.
|
|
|
|
|
|
|
|
|
|
"""
|
2020-01-07 14:10:42 +00:00
|
|
|
view = PathDownloadView.as_view(
|
|
|
|
|
path=filename,
|
|
|
|
|
attachment=attachment,
|
|
|
|
|
basename=attachment_filename,
|
|
|
|
|
mimetype=mimetype,
|
|
|
|
|
encoding=encoding,
|
|
|
|
|
)
|
2013-11-28 23:55:46 +00:00
|
|
|
return view(request)
|