FEATURE: allow inline disposition on uploads

when linking an upload allow ?inline=1 to display upload inline
This commit is contained in:
Sam 2014-11-13 08:50:55 +11:00
parent 03bc91f204
commit 4fc3834dd6

View File

@ -34,7 +34,9 @@ class UploadsController < ApplicationController
# the "url" parameter is here to prevent people from scanning the uploads using the id
if upload = (Upload.find_by(id: id, url: url) || Upload.find_by(sha1: params[:sha]))
send_file(Discourse.store.path_for(upload), filename: upload.original_filename)
opts = {filename: upload.original_filename}
opts[:disposition] = 'inline' if params[:inline]
send_file(Discourse.store.path_for(upload),opts)
else
render_404
end