-3

I want to build a API with Grape, which could be POST file through http streaming. How to do that?

PS grape example of rack-stream couldn't work

error info: HTTP/1.1 503 Service Unavailable

travo
  • 1
  • 1
  • *couldn't work* is not a valid issue description. Where is your code? What is your error? – Raptor Jun 26 '14 at 07:52
  • What I've tried: 1. Clone files from [grape example][1] 2. sudo apt-get install redis-server in my Ubuntu 12.04 x64 3. thin start -p 9292 4. curl -i -N address-of-api, and I got "HTTP/1.1 503 Service Unavailable" – travo Jun 26 '14 at 08:10
  • Did you start the redis server? – Neil Slater Jun 26 '14 at 09:42

1 Answers1

0

I want to make grape can handle request like this:

Net::HTTP.new('localhost', 9292).start do |h|
  req = Net::HTTP::Post.new('/api/http_streaming_post')
  File.open('binary_file.bin') do |f|
    req.body_stream = f
    req['Content-Length'] = f.lstat.size.to_s
    req['Content-Type'] = 'text/html;charset=utf-8'
    response = h.request req
  end
end

I don't know how to do it.

After found reading body_stream in sinatra, I use sinatra instead.

Community
  • 1
  • 1
travo
  • 1
  • 1