Skip to content

Commit

Permalink
Add ability to download files.
Browse files Browse the repository at this point in the history
This happens through Sinatra right now, might change that.
  • Loading branch information
Mike Leone committed Aug 18, 2010
1 parent 8a1d74b commit 7176b6a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions broadcast.rb
Expand Up @@ -23,6 +23,11 @@ class Broadcast < Sinatra::Base
render_file_tree params[:dir]
end

get "/download" do
file = File.join MEDIA_DIR + params[:file]
send_file(file, :disposition => 'attachment', :filename => File.basename(file))
end

get "/snapshot.jpg" do
content_type 'image/png'
capture_picture_data
Expand Down
5 changes: 5 additions & 0 deletions test.rb
Expand Up @@ -33,6 +33,11 @@ def test_get_location
assert last_response.ok?
end

def test_download
get '/download?file=/snapshots/latest.jpg'
assert last_response.ok?
end

def test_tts
post '/say.json'
assert last_response.ok?
Expand Down

0 comments on commit 7176b6a

Please sign in to comment.