Module: ActiveFedora::File::Streaming

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

Defined Under Namespace

Classes: FileBody

Instance Method Summary collapse

Instance Method Details

#authorization_keyObject


307
308
309
# File 'lib/active_fedora/file.rb', line 307

def authorization_key
  self.ldp_source.client.http.headers.fetch("Authorization", nil)
end

#headers(range, key, result = Hash.new) ⇒ Object

Parameters:

  • range (String)

    from #stream

  • key (String)

    from #authorization_key


314
315
316
317
318
# File 'lib/active_fedora/file.rb', line 314

def headers(range, key, result = Hash.new)
  result["Range"] = range if range
  result["Authorization"] = key if key
  result
end

#stream(range = nil) ⇒ Object

Parameters:

  • range (String) (defaults to: nil)

    the Range HTTP header


301
302
303
304
# File 'lib/active_fedora/file.rb', line 301

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