Module: KalturaFu::Entry::ClassMethods

Defined in:
lib/kaltura_fu/entry/class_methods.rb

Overview

Class level methods for the Entry module.

Instance Method Summary collapse

Instance Method Details

#construct_entry_from_options(options = {}) ⇒ Object



50
51
52
53
54
55
56
57
# File 'lib/kaltura_fu/entry/class_methods.rb', line 50

def construct_entry_from_options(options={})
  media_entry = Kaltura::MediaEntry.new
  options.each do |key,value|
    media_entry.send("#{key}=",value) if valid_entry_attribute?(key)
  end
    media_entry.media_type = Kaltura::Constants::Media::Type::VIDEO if options[:media_type].nil?
    return media_entry
end

#findObject

TODO:

Build find.



35
36
37
# File 'lib/kaltura_fu/entry/class_methods.rb', line 35

def find
  #pending
end

#upload(upload_object, options = {}) ⇒ String

TODO:

Add the other upload types.

extend KalturaFu::Entry::Metadata

Allows you to upload some variety of media into Kaltura.

This isn’t going to be as great to use as one of their flash widgets, and should likely be used “off” the web process to not slow the application down.

Parameters:

  • upload_object

    The object to upload. Currently, it only works with a File.

  • options (Hash) (defaults to: {})

    An options hash of Kaltura Media Entry attributes to add & the upload_object source.

Options Hash (options):

  • :source(nil) (Symbol)

    Currently only accepts :file

Returns:

  • (String)

    Returns the Kaltura Media Entry’s ID that was created.

Raises:

  • (Kaltura::APIError)

    It will force a Kaltura::APIError if something went terribly wrong.



24
25
26
27
28
29
30
# File 'lib/kaltura_fu/entry/class_methods.rb', line 24

def upload(upload_object,options={})
  KalturaFu.check_for_client_session
  
  #options_for_media_entry = options.delete(:source)
  media_entry = construct_entry_from_options(options)
  upload_from_file(upload_object,media_entry) if options[:source] == :file
end

#upload_from_file(upload_object, media_entry) ⇒ Object



42
43
44
45
# File 'lib/kaltura_fu/entry/class_methods.rb', line 42

def upload_from_file(upload_object,media_entry)
  upload_token = KalturaFu.client.media_service.upload(upload_object)
  KalturaFu.client.media_service.add_from_uploaded_file(media_entry,upload_token).id
end