yukimotopress / http

Net::HTTP by Example / Net::HTTP Cheat Sheet (Book Edition) by August Lilleaas, et al
17 stars 3 forks source link

PUT example uses form data and lacks binary data example #1

Open mlt opened 4 years ago

mlt commented 4 years ago

It took me a while to figure out how to feed data to Apache Tika Server content analyzer as it wants simple PUT with binary file content. The equivalent for

curl -T somestuff.dat http://localhost:9998/meta --header "Accept: application/json"

would be

uri = URI.parse('http://localhost:9998/meta')
http = Net::HTTP.new(uri.host, uri.port)
dat = File.read('somestuff.dat')
response = http.request_put(uri.path, dat, Accept: 'application/json', 'Content-Type': 'application/octet-stream')
geraldb commented 4 years ago

Thanks for the PUT example with binary data.