Class: UploadController

Inherits:
ApplicationController show all
Defined in:
app/controllers/upload_controller.rb

Instance Method Summary collapse

Instance Method Details

#gpxObject

return GPX file content enclosed in JSON response



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/upload_controller.rb', line 4

def gpx
  if user_signed_in?
    uploaded_io = params[:gpx_file]
    if uploaded_io.tempfile.size <= 1048576
      # NOTE: use content type "text/html" for file upload response
      #       see http://docs.sencha.com/ext-js/4-0/#!/api/Ext.form.Basic-method-hasUpload
      render :text => CGI::escapeHTML({:success => true, :gpx => uploaded_io.read, :filename => uploaded_io.original_filename}.to_json)
    else
      render :text => CGI::escapeHTML({:success => false, :msg => "File size must be less than 1MB"}.to_json)
    end
  else
    render :nothing => true, :status => 404
  end
end