mirror of
https://github.com/fergalmoran/dss.git
synced 2025-12-22 09:38:18 +00:00
Added x-sendfile support
This commit is contained in:
0
_working/create
Executable file → Normal file
0
_working/create
Executable file → Normal file
@@ -216,3 +216,7 @@ PIPELINE_CSS = {
|
||||
}
|
||||
INTERNAL_IPS = ('127.0.0.1',)
|
||||
GOOGLE_ANALYTICS_CODE = localsettings.GOOGLE_ANALYTICS_CODE
|
||||
|
||||
SENDFILE_BACKEND = localsettings.SENDFILE_BACKEND
|
||||
SENDFILE_ROOT = os.path.join(MEDIA_ROOT, 'mixes')
|
||||
SENDFILE_URL = '/mixes'
|
||||
16
spa/audio.py
16
spa/audio.py
@@ -2,13 +2,9 @@ from wsgiref.util import FileWrapper
|
||||
from django.conf.urls import url
|
||||
from django.http import HttpResponse, Http404
|
||||
import os
|
||||
from sendfile import sendfile
|
||||
from spa.models.Mix import Mix
|
||||
|
||||
class FixedFileWrapper(FileWrapper):
|
||||
def __iter__(self):
|
||||
self.filelike.seek(0)
|
||||
return self
|
||||
|
||||
class AudioHandler(object):
|
||||
@property
|
||||
def urls(self):
|
||||
@@ -22,13 +18,15 @@ def start_streaming(request, mix_id):
|
||||
mix = Mix.objects.get(pk=mix_id)
|
||||
if mix is not None:
|
||||
filename = mix.local_file.file.name # Select your file here.
|
||||
wrapper = FixedFileWrapper(open(filename, 'rb'))
|
||||
response = HttpResponse(wrapper, content_type='audio/mpeg')
|
||||
response = sendfile(request, filename)
|
||||
"""
|
||||
#wrapper = FixedFileWrapper(open(filename, 'rb'))
|
||||
response = HttpResponse(FileIterWrapper(open(filename)), content_type='audio/mpeg')
|
||||
response['Content-Length'] = os.path.getsize(filename)
|
||||
response['Content-Type'] = "audio/mpeg"
|
||||
response['Content-Disposition'] = "inline; filename=stream.mp3"
|
||||
response['Cache-Control'] = "no-cache"
|
||||
response['Content-Transfer-Encoding'] = "binary"
|
||||
response['Cache-Control'] = "no-cache"
|
||||
"""
|
||||
return response
|
||||
except Exception, ex:
|
||||
print ex
|
||||
|
||||
@@ -62,6 +62,7 @@ class Mix(_BaseModel):
|
||||
return settings.STATIC_URL + 'img/default-track.png'
|
||||
|
||||
def get_stream_path(self):
|
||||
#return 'media/%s/' % self.local_file.name
|
||||
return '/audio/stream/%d' % self.id;
|
||||
|
||||
@classmethod
|
||||
|
||||
0
static/bin/sm/soundmanager2.swf
Executable file → Normal file
0
static/bin/sm/soundmanager2.swf
Executable file → Normal file
0
static/bin/sm/soundmanager2_debug.swf
Executable file → Normal file
0
static/bin/sm/soundmanager2_debug.swf
Executable file → Normal file
0
static/bin/sm/soundmanager2_flash9.swf
Executable file → Normal file
0
static/bin/sm/soundmanager2_flash9.swf
Executable file → Normal file
0
static/bin/sm/soundmanager2_flash9_debug.swf
Executable file → Normal file
0
static/bin/sm/soundmanager2_flash9_debug.swf
Executable file → Normal file
0
static/img/whats-on.png
Executable file → Normal file
0
static/img/whats-on.png
Executable file → Normal file
|
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 6.0 KiB |
0
static/js/libs/sm/soundmanager2.js
Executable file → Normal file
0
static/js/libs/sm/soundmanager2.js
Executable file → Normal file
Reference in New Issue
Block a user