I think your Grape code is fine, I tested it with a browser and the Mac HTTP tool (called GraphicalHTTPClient), which I use to test the API. I successfully downloaded the binary from disk and passed it with the MIME type 'application/octet-stream' using an almost identical code for yours:
get :download do data = File.open('binary_data').read content_type 'application/octet-stream' body data end
I suggest your problem with the API client and / or character encoding (as Stuart M suggests). Although another possibility that arises for me is our discussion so far, that some rack middleware does not start correctly and modifies the output from Grape.
source share