Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6765743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:44:53+00:00 2026-05-26T14:44:53+00:00

I’m still new to Ruby and Rails so please excuse my question if the

  • 0

I’m still new to Ruby and Rails so please excuse my question if the answer is obvious. I have an application running with a controller called bucket which when passed an id connects to a non-routable subnet (10.0.0.xx) and returns data assuming some conditions are met. I’m currently using the send_data method in the bucket controller but since this expects a local file I’m reading the contents of the url into a string and then returning that.

This is good enough for very small files but for large binaries it’s too slow. What I really want to be able to do is stream the data back using /bucket as a proxy.

Here is the code from the controller I’m currently using:

fileName = "somename.dat"        
content = open(link) {|f| f.read() }
send_data content, :disposition=>'attachment', :filename=>fileName

I was hoping someone may have some advice on how to improve this. Ideally, I could read the data in chunks and return it as I received it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:44:54+00:00Added an answer on May 26, 2026 at 2:44 pm

    Check out rack-proxy, which will read from the private server and pass on the data for you.

    Install by adding gem 'rack-proxy' to your Bundle

    To configure, subclass.

    Example:

    class FooBar < Rack::Proxy
    
      def rewrite_env(env)
        env["HTTP_HOST"] = "example.com"
    
        env
      end
    
      def rewrite_response(triplet)
        status, headers, body = triplet
    
        headers["X-Foo"] = "Bar"
    
        triplet
      end
    
    end
    

    For more examples, read the tests.

    As a rack app, rack-proxy can be mounted in your rails 3 app as simply as:

    mount FooBar, :at => "/foo_bar"
    

    If you want to find out more about the role rack plays in the Rails ecosystem, here are the docs.

    If you don’t like this proxy, or you want some more ideas, check out a different implementation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I want use html5's new tag to play a wav file (currently only supported
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.