Implement track/stream

* Add Streamer class
* Use FactoryGirl for factories
* Add sha256 field to tracks
* Add mime_type field to tracks
This commit is contained in:
Thibault Jouan
2011-07-23 16:30:51 +00:00
parent 47fa969617
commit 2f6a447416
18 changed files with 166 additions and 51 deletions

View File

@@ -9,10 +9,10 @@ class TracksController < ApplicationController
def create
@track = Track.new(:name => params[:track][:name])
if params[:track][:file]
@track.uploaded_file = params[:track][:file]
end
if @track.save
if @track.save_with_file(
params[:track][:file].tempfile,
params[:track][:file].content_type
)
redirect_to @track
else
render :new
@@ -20,5 +20,8 @@ class TracksController < ApplicationController
end
def stream
track = Track.find params[:id]
self.content_type = track.mime_type
self.response_body = Streamer.new(track.filepath)
end
end