Skip to content

Instantly share code, notes, and snippets.

@dtjm
Created October 11, 2010 01:00
Show Gist options
  • Save dtjm/619788 to your computer and use it in GitHub Desktop.
Save dtjm/619788 to your computer and use it in GitHub Desktop.
require 'sinatra'
require 'net/http/post/multipart'
get '/' do
file = Tempfile.new("temp.txt")
file << "test contents"
file.flush
request = Net::HTTP::Post::Multipart.new(
"http://localhost:4567/upload",
'file' => UploadIO.convert!(
file,
'application/octet-stream',
"temp.txt",
file.path))
response = Net::HTTP.start("localhost", 4567) { |http| http.request(request) }
return response.body
end
post '/upload' do
p params
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment