xxxxxxxxxx
import mimetypes, os
from wsgiref.util import FileWrapper
from django.http import HttpResponse
def function(self):
my_file = 'path/to/file.svg'
response = HttpResponse(FixedFileWrapper(open(my_file, 'rb')), content_type=mimetypes.guess_type(my_file)[0])
response['Content-Length'] = os.path.getsize(my_file)
reponse['Content-Disposition'] = "attachment; filename=%s" % os.path.basename(my_file)
return response