Module: ActiveFedora::File::Streaming

Included in:
ActiveFedora::File
Defined in:
lib/active_fedora/file/streaming.rb

Defined Under Namespace

Classes: FileBody

Instance Method Summary collapse

Instance Method Details

#headers(range, key, result = {}) ⇒ Hash

Parameters:

  • range (String)

    from #stream

  • key (String)

    from #authorization_key

Returns:

  • (Hash)


12
13
14
15
16
# File 'lib/active_fedora/file/streaming.rb', line 12

def headers(range, key, result = {})
  result["Range"] = range if range
  result["Authorization"] = key if key
  result
end

#stream(range = nil) ⇒ Stream

Returns an object that responds to each.

Parameters:

  • range (String) (defaults to: nil)

    the Range HTTP header

Returns:

  • (Stream)

    an object that responds to each



4
5
6
7
# File 'lib/active_fedora/file/streaming.rb', line 4

def stream(range = nil)
  uri = URI.parse(self.uri)
  FileBody.new(uri, headers(range, authorization_key))
end