2

I am trying to stream data stored on Amazon S3 to a client. Unfortunately, I am unable to redirect to the bucket with a presigned URL in order to support such files as HTML which require the original HTML file to be served from the same domain as its assets (css, etc..).

After reading http://apidock.com/rails/ActionController/Base/render

It seemed to me as though I should be able to do the following:

 render :text => proc { |response, output|
   s3_object.get(response_target: output)
 end

However, the output of this on the page was just the result of proc.to_s

Similarly, the example provided in the Rails docs:

 render :text => proc { |response, output|
    100.times do |i|
      output.write("This is line #{i}\n")
    end
  }

Seems to do the same.

Has anyone run into this problem? Is there a reason why Rails is not properly rendering the results of the lambda instead of calling .to_s?

Thanks.

1 Answers1

2

As your link suggests this option was available till Rails 2.3.8.

It was deprecated from Rails 3.

Here's an old day discussion showing problems with this feature: https://groups.google.com/forum/#!topic/rubyonrails-core/BnVHfD-yO_I.

dimakura
  • 7,575
  • 17
  • 36
  • Awesome thanks, missed the deprecation notice. This other stackoverflow post helped as well: http://stackoverflow.com/questions/3507594/ruby-on-rails-3-streaming-data-through-rails-to-client – nothingness Oct 02 '15 at 06:59