Created
December 2, 2011 00:07
-
-
Save fender21/1420876 to your computer and use it in GitHub Desktop.
Better way to route?
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
post :index do | |
#determine the querystring which is NOT restful and route to approriate view | |
#URL looks like this http://localhost/app?create&id=10 | |
url = env['REQUEST_URI'] | |
uri = Addressable::URI.parse(url).query_values.to_hash | |
#Provide Server Info text per spec | |
if uri.has_key?("create") | |
tmp_dir = File.join(Padrino.root, 'tmp') | |
raw_data = request.body.read.force_encoding('UTF-8') | |
file_name = File.join(tmp_dir, params[:docId]) | |
# #save out file | |
File.open("#{file_name}.pdf", 'w') do |f| | |
f.write(raw_data) | |
status 200 | |
end | |
end | |
# File.open("#{file_name}-params.txt", 'w') do |f| | |
# f.write(params.to_s) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment