Class: ActiveFedora::File::Streaming::FileBody
- Inherits:
-
Object
- Object
- ActiveFedora::File::Streaming::FileBody
- Defined in:
- lib/active_fedora/file/streaming.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(no_of_requests_limit = 3) ⇒ Object
-
#initialize(uri, headers) ⇒ FileBody
constructor
A new instance of FileBody.
Constructor Details
#initialize(uri, headers) ⇒ FileBody
Returns a new instance of FileBody.
20 21 22 23 |
# File 'lib/active_fedora/file/streaming.rb', line 20 def initialize(uri, headers) @uri = uri @headers = headers end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
19 20 21 |
# File 'lib/active_fedora/file/streaming.rb', line 19 def headers @headers end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
19 20 21 |
# File 'lib/active_fedora/file/streaming.rb', line 19 def uri @uri end |
Instance Method Details
#each(no_of_requests_limit = 3) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/active_fedora/file/streaming.rb', line 25 def each(no_of_requests_limit = 3) redirecting_connection(no_of_requests_limit).get(uri.to_s, nil, headers) do |req| req..on_data = proc do |chunk, overall_received_bytes, _env| yield chunk unless overall_received_bytes.zero? # Don't yield when redirecting end end rescue Faraday::FollowRedirects::RedirectLimitReached raise ArgumentError, 'HTTP redirect too deep' rescue Faraday::Error => ex raise "Couldn't get data from Fedora (#{uri}). Response: #{ex.response_status}" end |