Method: Yt::Models::ContentOwner#upload_reference_file

Defined in:
lib/yt/models/content_owner.rb

#upload_reference_file(path_or_url, params = {}) ⇒ Yt::Models::Reference

Uploads a reference file to YouTube.

Parameters:

  • path_or_url (String)

    is the video or audio file to upload. Can either be the path of a local file or the URL of a remote file.

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

    the metadata to add to the uploaded reference.

Options Hash (params):

  • :asset_id (String)

    The id of the asset the uploaded reference belongs to.

  • :content_type (String)

    The type of content being uploaded.

Returns:



56
57
58
59
60
61
62
63
# File 'lib/yt/models/content_owner.rb', line 56

def upload_reference_file(path_or_url, params = {})
  file = URI.open(path_or_url)
  session = resumable_sessions.insert file.size, params

  session.update(body: file) do |data|
    Yt::Reference.new id: data['id'], data: data, auth: self
  end
end