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

#upload_video(file) ⇒ Yt::Models::Video

Uploads a video using the current resumable session

Parameters:

  • file (#read)

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

Returns:



20
21
22
23
24
# File 'lib/yt/models/resumable_session.rb', line 20

def upload_video(file)
  do_update(body: file) do |data|
    Yt::Video.new id: data['id'], snippet: data['snippet'], status: data['privacyStatus'], auth: @auth
  end
end