Skip to content

Commit

Permalink
Set the Content-Length header for downloads
Browse files Browse the repository at this point in the history
Without a Content-Length header on an audio/video file the browser will either
not show a scrubber or disable it.
  • Loading branch information
jcoyne committed Aug 28, 2015
1 parent 9b49d4d commit 5fb2c34
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def show
super
when String
# For derivatives stored on the local file system
response.headers['Content-Length'] = File.size(file).to_s
send_file file, type: mime_type_for(file), disposition: 'inline'
else
render_404
Expand Down
1 change: 1 addition & 0 deletions spec/controllers/downloads_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
it 'sends requested file content' do
get :show, id: generic_file, file: 'thumbnail'
expect(response.body).to eq content
expect(response.headers['Content-Length']).to eq "4218"
end
end

Expand Down

0 comments on commit 5fb2c34

Please sign in to comment.