def sendfile(request, filename, attachment=False, attachment_filename=None, mimetype=None, encoding=None, backend=None):
 _sendfile = (backend or _get_sendfile())
 if (not os.path.exists(filename)):
  from django.http import Http404
  raise Http404((u'"%s" does not exist' % filename))
 (guessed_mimetype, guessed_encoding) = guess_type(filename)
 if (mimetype is None):
  if guessed_mimetype:
   mimetype = guessed_mimetype
  else:
   mimetype = u'application/octet-stream'
 response = _sendfile(request, filename, mimetype=mimetype)
 if attachment:
  if (attachment_filename is None):
   attachment_filename = os.path.basename(filename)
  parts = [u'attachment']
  if attachment_filename:
   from unidecode import unidecode
   try:
    from django.utils.encoding import force_text
   except ImportError:
    from django.utils.encoding import force_unicode as force_text
   attachment_filename = force_text(attachment_filename)
   ascii_filename = unidecode(attachment_filename)
   parts.append((u'filename="%s"' % ascii_filename))
   if (ascii_filename != attachment_filename):
    from django.utils.http import urlquote
    quoted_filename = urlquote(attachment_filename)
    parts.append((u"filename*=UTF-8''%s" % quoted_filename))
  response[u'Content-Disposition'] = u'; '.join(parts)
 response[u'Content-length'] = os.path.getsize(filename)
 response[u'Content-Type'] = mimetype
 if (not encoding):
  encoding = guessed_encoding
 if encoding:
  response[u'Content-Encoding'] = encoding
 return response

def sendfile ( request , filename , attachment = False , attachment_filename = None , mimetype = None , encoding = None , backend = None ) : _sendfile = ( backend or _get_sendfile ( ) ) if ( not os . path . exists ( filename ) ) : from django . http import Http404 raise Http404 ( ( u'"%s" does not exist' % filename ) ) ( guessed_mimetype , guessed_encoding ) = guess_type ( filename ) if ( mimetype is None ) : if guessed_mimetype : mimetype = guessed_mimetype else : mimetype = u'application/octet-stream' response = _sendfile ( request , filename , mimetype = mimetype ) if attachment : if ( attachment_filename is None ) : attachment_filename = os . path . basename ( filename ) parts = [ u'attachment' ] if attachment_filename : from unidecode import unidecode try : from django . utils . encoding import force_text except ImportError : from django . utils . encoding import force_unicode as force_text attachment_filename = force_text ( attachment_filename ) ascii_filename = unidecode ( attachment_filename ) parts . append ( ( u'filename="%s"' % ascii_filename ) ) if ( ascii_filename != attachment_filename ) : from django . utils . http import urlquote quoted_filename = urlquote ( attachment_filename ) parts . append ( ( u"filename*=UTF-8''%s" % quoted_filename ) ) response [ u'Content-Disposition' ] = u'; ' . join ( parts ) response [ u'Content-length' ] = os . path . getsize ( filename ) response [ u'Content-Type' ] = mimetype if ( not encoding ) : encoding = guessed_encoding if encoding : response [ u'Content-Encoding' ] = encoding return response
dummy sendfile backend implementation .