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



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

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.



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

def find
  #pending
end

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

TODO:

Add the other upload types.

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 (File)

    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.



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

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



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

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