Skip to content

Instantly share code, notes, and snippets.

@rkh

rkh/upload.ru Secret

Created December 13, 2011 08:32
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save rkh/57c8449e305a55a80e21 to your computer and use it in GitHub Desktop.
Save rkh/57c8449e305a55a80e21 to your computer and use it in GitHub Desktop.
app = proc do |env|
response = Rack::Response.new
request = Rack::Request.new(env)
info = request.params['info']
if info and info[:tempfile]
response['Content-Type'] = info[:type]
response.body = info[:tempfile].readlines.sort
else
response['Content-Type'] = 'text/plain'
response.status = 400
response.write "info parameter must be a file uplad"
end
response.finish
end
run app
@smtalim
Copy link

smtalim commented Dec 20, 2011

Usage:

$ rackup upload.ru

File alpha.txt contains:

zebra
yen
xmas
birthday
cat
apple
pune
mumbai
nashville

Client:

$ curl -F "info=@alpha.txt" localhost:9292

Result:

apple
birthday
cat
mumbai
nashville
pune
xmas
yen
zebra

@theFreedomBanana
Copy link

Very useful thxs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment