Debian Codegraph @

django_downloadview/shortcuts.py

raw
1 """Port of django-sendfile in django-downloadview."""
2
3 from django_downloadview.views.path import PathDownloadView
4
5
6 def sendfile(
7 request,
8 filename,
9 attachment=False,
10 attachment_filename=None,
11 mimetype=None,
12 encoding=None,
13 ):
14 """Port of django-sendfile's API in django-downloadview.
15
16 Instantiates a :class:`~django_downloadview.views.path.PathDownloadView` to
17 stream the file by ``filename``.
18
19 """
20 view = PathDownloadView.as_view(
21 path=filename,
22 attachment=attachment,
23 basename=attachment_filename,
24 mimetype=mimetype,
25 encoding=encoding,
26 )
27 return view(request)