django_sendfile.utils module
- django_sendfile.utils.sendfile(request, filename, attachment=False, attachment_filename=None, mimetype=None, encoding=None)[source]
Create a response to send file using backend configured in
SENDFILE_BACKEND
filename
is the absolute path to the file to send.If
attachment
isTrue
theContent-Disposition
header will be set accordingly. This will typically prompt the user to download the file, rather than view it. But even ifFalse
, the user may still be prompted, depending on the browser capabilities and configuration.The
Content-Disposition
filename depends on the value ofattachment_filename
:None
(default): Same asfilename
False
: NoContent-Disposition
filenameString
: Value used as filenameIf neither
mimetype
orencoding
are specified, then they will be guessed via the filename (using the standard Python mimetypes module)