Created
August 2, 2013 07:00
-
-
Save hnakagawa/6137991 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
require 'sinatra' | |
post '/upload' do | |
p params | |
unless params[:test] && | |
(tmpfile = params[:test][:tempfile]) && | |
(name = params[:test][:filename]) | |
@error = "No file selected" | |
return 'error' | |
end | |
STDERR.puts "Uploading file, original name #{ name.inspect}" | |
while blk = tmpfile.read(65536) | |
# here you would write it to its final location | |
STDERR.puts blk.inspect | |
end | |
"Upload complete" | |
end | |
set :port, 8189 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ gem install sinatra
$ ruby multipart.rb -o 0.0.0.0