django_sendfile.utils module
- django_sendfile.utils.sendfile(request, filename, attachment=False, attachment_filename=None, mimetype=None, encoding=None, content_length=None)[source]
Create a response to send file using backend configured in
SENDFILE_BACKENDfilenameis the absolute path to the file to send.If
attachmentisTruetheContent-Dispositionheader 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-Dispositionfilename depends on the value ofattachment_filename:None(default): Same asfilenameFalse: NoContent-DispositionfilenameString: Value used as filenameIf neither
mimetypeorencodingare specified, then they will be guessed via the filename (using the standard Python mimetypes module)