Skip to content

Commit

Permalink
Andriod browsers are served files as attachments instead of inline. H…
Browse files Browse the repository at this point in the history
…aris test on his phone and the behavior now works like it previously did. [#20 state:resolved responsible:"Brian Michalski"]
  • Loading branch information
bamnet committed Apr 29, 2010
1 parent ba08217 commit ba6e9ba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/controllers/application_controller.rb
Expand Up @@ -5,6 +5,12 @@ class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryProtection for details

# Request from an Android?
def android_user_agent?
request.env["HTTP_USER_AGENT"] && request.env["HTTP_USER_AGENT"][/(Android)/]
end


def redirect_back
#if authorization fails, redirect back
redirect_to :back
Expand Down
8 changes: 7 additions & 1 deletion app/controllers/revisions_controller.rb
Expand Up @@ -119,10 +119,16 @@ def download
revision.document.bypass_auth do
revision.document.increment!(:downloaded)
end

disposition = 'inline'
if android_user_agent?
disposition = 'attachment'
end

send_data revision.upload.file_contents(:original),
:filename => revision.upload_file_name,
:type => revision.upload_content_type,
:disposition => 'inline'
:disposition => disposition
else
redirect_back
end
Expand Down

0 comments on commit ba6e9ba

Please sign in to comment.