Created
October 29, 2009 14:48
-
-
Save zenchild/221483 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
# 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