An ActiveFedora mixin that allows a datastream dissemination response to be streamed back in blocks without reading all content into memory.
Include the mixin in your ActiveFedora::Datastream subclass:
class BigData < ActiveFedora::Datastream
include ActiveFedora::Streamable::Datastreams
end
class DataContainer < ActiveFedora::Base
has_file_datastream :name=>'bigData', :type=> BigData
end
and then set the response_body in your controller:
DataContainer.find('demo:1').bigData.stream(self)
The iterator returned from #stream will write the bytes of a datastream dissemination back to the client in segments, without reading all of the content into memory first. It will not assign the output of the datastream dissemination to the ActiveFedora::Datastream’s content attribute.