X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/2c98558c86f50a26b96d4b0feebdb93195a10455..d781f42016767132eea7c7463549640d943c2910:/app/controllers/trace_controller.rb diff --git a/app/controllers/trace_controller.rb b/app/controllers/trace_controller.rb index 478109eb0..1fb0b5c65 100644 --- a/app/controllers/trace_controller.rb +++ b/app/controllers/trace_controller.rb @@ -120,8 +120,10 @@ class TraceController < ApplicationController def data trace = Trace.find(params[:id]) - if trace.public? or (@user and @user == trace.user) - send_data(File.open("/home/osm/gpx/#{trace.id}.gpx",'r').read , :filename => "#{trace.id}.gpx", :type => 'text/plain', :disposition => 'inline') + if trace and (trace.public? or (@user and @user == trace.user)) + send_file(trace.trace_name, :filename => "#{trace.id}.gpx", :type => trace.mime_type, :disposition => 'attachment') + else + render :nothing, :status => 404 end end @@ -152,12 +154,20 @@ class TraceController < ApplicationController def picture trace = Trace.find(params[:id]) - send_data(trace.large_picture, :filename => "#{trace.id}.gif", :type => 'image/gif', :disposition => 'inline') if trace.public? or (@user and @user == trace.user) + if trace and (trace.public? or (@user and @user == trace.user)) + send_file(trace.large_picture_name, :filename => "#{trace.id}.gif", :type => 'image/gif', :disposition => 'inline') + else + render :nothing, :status => 404 + end end def icon trace = Trace.find(params[:id]) - send_data(trace.icon_picture, :filename => "#{trace.id}_icon.gif", :type => 'image/gif', :disposition => 'inline') if trace.public? or (@user and @user == trace.user) + if trace and (trace.public? or (@user and @user == trace.user)) + send_file(trace.icon_picture_name, :filename => "#{trace.id}_icon.gif", :type => 'image/gif', :disposition => 'inline') + else + render :nothing, :status => 404 + end end def api_details