Skip to content

Instantly share code, notes, and snippets.

@zenchild
Created October 29, 2009 14:48
Show Gist options
  • Save zenchild/221483 to your computer and use it in GitHub Desktop.
Save zenchild/221483 to your computer and use it in GitHub Desktop.
# To get Sinatra PUT methods to work read the request body instead of params.
# This was discussed in the Sinatra Google group:
# http://groups.google.com/group/sinatrarb/browse_thread/thread/7d1a52806492d5ea/9615ffc455a6336c?lnk=gst&q=put#9615ffc455a6336c
require 'rubygems'
require 'sinatra'
put '/:id' do
if( ! File.exists? "outfiles" )
Dir.mkdir "outfiles"
end
f = File.open("outfiles/#{params[:id]}",'w+')
f.write(request.body.read)
f.close
"Yup\n"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment