1 # -*- coding: utf-8 -*-
2 from django.http import HttpResponse
5 def serve_file(file_path, name, mime_type):
6 def read_chunks(f, size=8192):
12 response = HttpResponse(content_type=mime_type)
13 response['Content-Disposition'] = 'attachment; filename=%s' % name
14 with open(file_path) as f:
15 for chunk in read_chunks(f):