how to send_data or attached file with goliath and grape?

644 views Asked by At

not sure how this is done, but following how's its done in Sinatra wouldn't cut it on Goliath - How can I send binary data from Sinatra?

1

There are 1 answers

0
dj2 On

You can set the 'Content-Type' header into the headers hash and then just send the data back, if your file is small enough.

[200, {'Content-Type' => 'application/octet-stream'}, "\x01\x02\x03"] 

If the file is large, you can do chunked streaming of the response, take a look in the examples directory of Goliath to see a couple of streaming samples.