@@ -16,17 +16,22 | |||||
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | class AttachmentsController < ApplicationController |
|
18 | class AttachmentsController < ApplicationController | |
|
19 | layout 'base' | |||
19 | before_filter :find_project, :check_project_privacy |
|
20 | before_filter :find_project, :check_project_privacy | |
20 |
|
21 | |||
21 | # sends an attachment |
|
22 | # sends an attachment | |
22 | def download |
|
23 | def download | |
23 | send_file @attachment.diskfile, :filename => @attachment.filename |
|
24 | send_file @attachment.diskfile, :filename => @attachment.filename | |
|
25 | rescue | |||
|
26 | render_404 | |||
24 | end |
|
27 | end | |
25 |
|
28 | |||
26 | # sends an image to be displayed inline |
|
29 | # sends an image to be displayed inline | |
27 | def show |
|
30 | def show | |
28 | render(:nothing => true, :status => 404) and return unless @attachment.diskfile =~ /\.(jpeg|jpg|gif|png)$/i |
|
31 | render(:nothing => true, :status => 404) and return unless @attachment.diskfile =~ /\.(jpeg|jpg|gif|png)$/i | |
29 | send_file @attachment.diskfile, :type => "image/#{$1}", :disposition => 'inline' |
|
32 | send_file @attachment.diskfile, :type => "image/#{$1}", :disposition => 'inline' | |
|
33 | rescue | |||
|
34 | render_404 | |||
30 | end |
|
35 | end | |
31 |
|
36 | |||
32 | private |
|
37 | private |
General Comments 0
You need to be logged in to leave comments.
Login now