How to stream object from AWS S3 to browser using Sinatra and AngularJS

I was able to stream an S3 object from disk to the browser using the following post request in Ruby:

post '/api/s3/download/?' do
   filepath = "/tmp/test.txt"
   send_file(filepath, :filename => File.basename(filepath))

And the following AngularJS in the javascript:

  .then(function(response) {
    var blob = new Blob([]);
    var objectUrl = URL.createObjectURL(blob);
    const anchor = angular.element('<a></a>');
    anchor.attr('href', objectUrl);
    anchor.attr('download', source);
    anchor.css('display', 'none');
  }, function(error_msg) {

I've tried the following in Ruby to get an S3 object as a StringIO where source is the S3 object key:

s3 =
bucket = s3.bucket('my_bucket')
data = bucket.object(source).get

Then I tried returning data.body as the response to the javascript but that didn't work.

How can I take a StringIO object and send it to the browser as an octet-stream without materializing the file to disk?