Class: Yt::Models::ResumableSession

Inherits:
Base
  • Object
show all
Defined in:
lib/yt/models/resumable_session.rb

Overview

Provides methods to upload videos with the resumable upload protocol.

Instance Method Summary collapse

Methods included from Associations::HasReports

#has_report

Methods included from Associations::HasViewerPercentages

#has_viewer_percentages

Methods included from Associations::HasOne

#has_one

Methods included from Associations::HasMany

#has_many

Methods included from Associations::HasAuthentication

#has_authentication

Constructor Details

#initialize(options = {}) ⇒ ResumableSession

Sets up a resumable session using the URI returned by YouTube



10
11
12
13
14
# File 'lib/yt/models/resumable_session.rb', line 10

def initialize(options = {})
  @uri = URI.parse options[:url]
  @auth = options[:auth]
  @headers = options[:headers]
end

Instance Method Details

#update(params = {}) ⇒ Object



16
17
18
# File 'lib/yt/models/resumable_session.rb', line 16

def update(params = {})
  do_update(params) {|data| yield data}
end

#upload_thumbnail(file) ⇒ Object

Uploads a thumbnail using the current resumable session

Parameters:

  • file (#read)

    A binary object that contains the image content. Can either be a File, a StringIO (for instance using open-uri), etc.

Returns:

  • the new thumbnail resource for the given image.

See Also:



25
26
27
# File 'lib/yt/models/resumable_session.rb', line 25

def upload_thumbnail(file)
  do_update(body: file) {|data| data['items'].first}
end