1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#!/usr/bin/env ruby # Thanks to: # https://gist.github.com/225381 require 'rubygems' require 'sinatra' require 'json' post '/blend/:filename' do output = Hash.new filename = File.join('up', params[:filename]) datafile = params[:data] File.open(filename, 'wb') do |file| file.write(datafile[:tempfile].read) end output['wrote'] = true content_type :json output.to_json end