Show a 404 error page if attachment can not be read.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@544 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
ef39db234b
commit
c99da15445
|
@ -16,17 +16,22 @@
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class AttachmentsController < ApplicationController
|
class AttachmentsController < ApplicationController
|
||||||
|
layout 'base'
|
||||||
before_filter :find_project, :check_project_privacy
|
before_filter :find_project, :check_project_privacy
|
||||||
|
|
||||||
# sends an attachment
|
# sends an attachment
|
||||||
def download
|
def download
|
||||||
send_file @attachment.diskfile, :filename => @attachment.filename
|
send_file @attachment.diskfile, :filename => @attachment.filename
|
||||||
|
rescue
|
||||||
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
# sends an image to be displayed inline
|
# sends an image to be displayed inline
|
||||||
def show
|
def show
|
||||||
render(:nothing => true, :status => 404) and return unless @attachment.diskfile =~ /\.(jpeg|jpg|gif|png)$/i
|
render(:nothing => true, :status => 404) and return unless @attachment.diskfile =~ /\.(jpeg|jpg|gif|png)$/i
|
||||||
send_file @attachment.diskfile, :type => "image/#{$1}", :disposition => 'inline'
|
send_file @attachment.diskfile, :type => "image/#{$1}", :disposition => 'inline'
|
||||||
|
rescue
|
||||||
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
Loading…
Reference in New Issue