Another possibility, if you are using either Apache or Lighttpd, is the X-Sendfile header, so that the Python process does not have to handle the content.
For lighttpd:   http://blog.lighttpd.net/articles/2006/07/02/x-sendfile
For Apache:     http://tn123.ath.cx/mod_xsendfile/

On Apr 26, 2010, at 10:41 AM, Nick Serra wrote:

Interesting. If the file is an mp3, maybe try:

file = open("/path/to/my/song.mp3", "rb").read()
response['Content-Disposition'] = 'attachment; filename=filename.mp3'
return HttpResponse(file, mimetype="audio/mpeg")


On Apr 26, 1:20 pm, Dexter <a.essel...@gmail.com> wrote:
Hi there,

I want to send an audio file via a django view, but I don't know how.

This doesn't seem to work:

return HttpResponse(open(song.path).read(), mimetype = "audio/ mpeg")
Can you guy's help me?

Grtz, Dexter

--
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 athttp://groups.google.com/group/django-users?hl=en .
--
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=en .
--
-- Christophe Pettus
   x...@thebuild.com

--
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=en.

Reply via email to