title: Django: let user download a large file
body: <p>I am building a private file upload site. Alice uploads a file, Bob downloads it.</p>
  
  <p>People other than Alice and Bob should not have access. I was first thinking about giving the file a complex name ( <code>http://domain/download/md5sum.zip</code>), but I want an expiring link. So something like <code>http://domain/download/tempkey/aaa123/file.zip</code>. This will give me more control over file downloading and logging.</p>
  
  <p>I found this: <a href="https://stackoverflow.com/a/2900646">https://stackoverflow.com/a/2900646</a> . It suggests the following:</p>
  
  <pre><code>class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
  
      def do_GET(self):
          # The URL the client requested
          print self.path
  
          # analyze self.path, map the local file location...
  
          # open the file, load the data
          with open('test.py') as f: data = f.read()
  
          # send the headers
          self.send_response(200)
          self.send_header('Content-type', 'application/octet-stream') # you may change the content type
          self.end_headers()
          # If the file is not found, send error code 404 instead of 200 and display a message accordingly, as you wish.
  
          # wfile is a file-like object. writing data to it will send it to the client
          self.wfile.write(data)
  </code></pre>
  
  <p>But how do I get this to work in Django? A views function should return a HTTPResponse object, which this doesn't do.</p>