That makes sense. I've tried using sendfile but i'm not getting the behavior I expect.
I'm using the simple backend: SENDFILE_BACKEND = 'sendfile.backends.xsendfile' And i'm sending the file like this: project_path = os.path.dirname(__file__) path = os.path.join(project_path, "..", "songs", song.file_name) return sendfile(request, path, attachment=True) But that's resulting in a file download in the browser which is not the behavior I get when i add an alias to apache and serve it that way. On Saturday, December 27, 2014 11:54:15 AM UTC-5, Tim Chase wrote: > > On 2014-12-27 08:00, Hanley Hansen wrote: > > I want to serve an mov file on the file system with Django the way > > Apache would. IBe managed to serve the file as a download but I'm > > looking to stream it so it plays in browser. I want to avoid > > setting up a alias in Apache. Though it's a static file I need to > > stream it securely based on the user. Is that possible? > > It sounds like you want to investigate the "Django sendfile" > > https://www.google.com/search?q=django+sendfile > > which makes use of headers which tell the wrapping server (Apache, > lighttpd, nginx, etc) to send a file straight from the file-system > without needing to keep your Django app in the loop. The request hits > your Django app, you do whatever auth check you need, and if it > passes, you use sendfile in/as your response to instruct your > web-server to send the corresponding file. There's a nice write-up at > > > http://www.sensibledevelopment.com/2010/11/django-sendfile-an-for-abstraction-large-file-serving-in-django/ > > > that shows how it's used. I believe it has the limitation that the > file has to come from the same server rather than a media-server, but > it does ease the load that serving directly from Django would cause. > > -tkc > > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e287214b-1528-477e-8a69-e1024f4f15c6%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.