SimpleTouch SimpleTouch -5 years ago 240
Ruby Question

Resumable YouTube Data API v3 uploads using Ruby

I am currently using the google-api-ruby-client to upload videos to Youtube API V3, but I can't find a way of getting the Youtube ID that is created by a resumable upload. The code I am trying to use is along the lines of:

media =, 'application/octet-stream')
yt_response = @client.execute!({
:api_method => @youtube.videos.insert,
:parameters => {
:part => 'snippet,status',
'uploadType' => 'resumable'
:body_object => file_details,
:media => media
return JSON.parse(yt_response.response.body)

But unfortunately for resumable uploads,
is blank. If I change the
then body is a JSON blob that contains the Youtube ID. The response for a resumable upload though is only the resumable session URI for the upload with an empty body. How do I go from that URI into the Youtube ID I just created?

Answer Source

Synthesizing the info from How to engage a Resumable upload to Google Drive using google-api-ruby client? and the existing multipart upload sample leads to

videos_insert_response = client.execute!(
  :api_method => youtube.videos.insert,
  :body_object => body,
  :media =>[:file], 'video/*'),
  :parameters => {
    'uploadType' => 'resumable',
    :part => body.keys.join(',')
puts "'#{}' (video id: #{}) was successfully uploaded."

That worked for me.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download