Skip to content

Instantly share code, notes, and snippets.

@jfryman
Created April 25, 2011 19:12
Show Gist options
  • Save jfryman/941020 to your computer and use it in GitHub Desktop.
Save jfryman/941020 to your computer and use it in GitHub Desktop.
# upload.rb
require 'rubygems'
require 'sinatra'
require 'FileUtils'
get '*' do
"Nothing to see here"
end
post '*' do
@docroot = "/tmp"
file = @docroot + params[:splat].first
FileUtils.mkdir_p File.dirname(file)
source = File.open(params[:data][:tempfile].path, 'r')
target = File.open(file, 'w')
target.write(source.read)
target.close if target
source.close if source
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment