Skip to content

Commit 8e4c4cd

Browse files
authored
serve icons through rails render (#5029)
1 parent b44fdde commit 8e4c4cd

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

apps/dashboard/app/controllers/apps_controller.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,18 @@ def icon
4646
set_app
4747
expires_in 365.days, public: true
4848

49-
if @app.svg_icon?
50-
send_file @app.icon_path, :type => 'image/svg+xml', :disposition => 'inline'
49+
if @app.svg_icon?
50+
content_type = 'image/svg+xml'
51+
dispostion_header = 'inline; filename="icon.svg"; filename*=UTF-8\'\'icon.svg'
5152
elsif @app.png_icon?
52-
send_file @app.icon_path, :type => 'image/png', :disposition => 'inline'
53+
content_type = 'image/png'
54+
dispostion_header = 'inline; filename="icon.png"; filename*=UTF-8\'\'icon.png'
5355
else
54-
raise ActionController::RoutingError.new('Not Found')
56+
raise(ActionController::RoutingError, 'Not Found')
5557
end
58+
59+
response.headers['content-disposition'] = dispostion_header
60+
render(file: @app.icon_path, layout: false, content_type: content_type)
5661
end
5762

5863
private

0 commit comments

Comments
 (0)