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
@@ -215,4 +215,8 @@ PIPELINE_CSS = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
INTERNAL_IPS = ('127.0.0.1',)
|
INTERNAL_IPS = ('127.0.0.1',)
|
||||||
GOOGLE_ANALYTICS_CODE = localsettings.GOOGLE_ANALYTICS_CODE
|
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.conf.urls import url
|
||||||
from django.http import HttpResponse, Http404
|
from django.http import HttpResponse, Http404
|
||||||
import os
|
import os
|
||||||
|
from sendfile import sendfile
|
||||||
from spa.models.Mix import Mix
|
from spa.models.Mix import Mix
|
||||||
|
|
||||||
class FixedFileWrapper(FileWrapper):
|
|
||||||
def __iter__(self):
|
|
||||||
self.filelike.seek(0)
|
|
||||||
return self
|
|
||||||
|
|
||||||
class AudioHandler(object):
|
class AudioHandler(object):
|
||||||
@property
|
@property
|
||||||
def urls(self):
|
def urls(self):
|
||||||
@@ -22,13 +18,15 @@ def start_streaming(request, mix_id):
|
|||||||
mix = Mix.objects.get(pk=mix_id)
|
mix = Mix.objects.get(pk=mix_id)
|
||||||
if mix is not None:
|
if mix is not None:
|
||||||
filename = mix.local_file.file.name # Select your file here.
|
filename = mix.local_file.file.name # Select your file here.
|
||||||
wrapper = FixedFileWrapper(open(filename, 'rb'))
|
response = sendfile(request, filename)
|
||||||
response = HttpResponse(wrapper, content_type='audio/mpeg')
|
"""
|
||||||
|
#wrapper = FixedFileWrapper(open(filename, 'rb'))
|
||||||
|
response = HttpResponse(FileIterWrapper(open(filename)), content_type='audio/mpeg')
|
||||||
response['Content-Length'] = os.path.getsize(filename)
|
response['Content-Length'] = os.path.getsize(filename)
|
||||||
response['Content-Type'] = "audio/mpeg"
|
response['Content-Type'] = "audio/mpeg"
|
||||||
response['Content-Disposition'] = "inline; filename=stream.mp3"
|
|
||||||
response['Cache-Control'] = "no-cache"
|
|
||||||
response['Content-Transfer-Encoding'] = "binary"
|
response['Content-Transfer-Encoding'] = "binary"
|
||||||
|
response['Cache-Control'] = "no-cache"
|
||||||
|
"""
|
||||||
return response
|
return response
|
||||||
except Exception, ex:
|
except Exception, ex:
|
||||||
print ex
|
print ex
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ class Mix(_BaseModel):
|
|||||||
return settings.STATIC_URL + 'img/default-track.png'
|
return settings.STATIC_URL + 'img/default-track.png'
|
||||||
|
|
||||||
def get_stream_path(self):
|
def get_stream_path(self):
|
||||||
|
#return 'media/%s/' % self.local_file.name
|
||||||
return '/audio/stream/%d' % self.id;
|
return '/audio/stream/%d' % self.id;
|
||||||
|
|
||||||
@classmethod
|
@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