Hello,

I have created a website where you can buy and download some files.
For security reasons all the files are served through a view, where
comprobations are made in order to assure that the user bought the
product.

The problem is that the files are at least 400Mb and some of them are
nearly 1Gb. Using this view is inefficient since all the content is
loaded into memory and it kills the server:

type, encoding = mimetypes.guess_type(file)
name = os.path.basename(file)
response = HttpResponse(mimetype=type)
response['Content-Disposition'] = 'attachment; filename=%s' %
(smart_str(name),)

f = open(file, 'r')
response.write(f.read())
f.close()
return response

How could I solve this problem?

Regards,

Adrian.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.


Reply via email to