Created
April 25, 2011 19:12
-
-
Save jfryman/941020 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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