Class: ActiveFedora::File::Streaming::FileBody
- Inherits:
-
Object
- Object
- ActiveFedora::File::Streaming::FileBody
- Defined in:
- lib/active_fedora/file.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(uri, headers) ⇒ FileBody
constructor
A new instance of FileBody.
Constructor Details
#initialize(uri, headers) ⇒ FileBody
Returns a new instance of FileBody.
322 323 324 325 |
# File 'lib/active_fedora/file.rb', line 322 def initialize(uri, headers) @uri = uri @headers = headers end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
321 322 323 |
# File 'lib/active_fedora/file.rb', line 321 def headers @headers end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
321 322 323 |
# File 'lib/active_fedora/file.rb', line 321 def uri @uri end |
Instance Method Details
#each ⇒ Object
327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/active_fedora/file.rb', line 327 def each Net::HTTP.start(uri.host, uri.port) do |http| request = Net::HTTP::Get.new uri, headers http.request request do |response| raise "Couldn't get data from Fedora (#{uri}). Response: #{response.code}" unless response.is_a?(Net::HTTPSuccess) response.read_body do |chunk| yield chunk end end end end |