from django.core.servers.basehttp import FileWrapper
def get_file(request):
filename = '...'
content_type = 'application/vnd.ms-excel'
file_path = os.path.join(store_path, filename)
response = HttpResponse(FileWrapper(file(file_path)), content_type=content_type)
response['Content-Disposition'] = 'attachment; filename=%s' % (
filename.encode('utf-8') if isinstance(filename, unicode) else filename,
)
response['Content-Length'] = os.path.getsize(path)
return response