Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to upload video on YouTube with Ruby
    text
    copied!<p>I am trying to upload a youtube video using the GData gem (I have seen the youtube_g gem but would like to make it work with pure GData if possible), but I keep getting this error:</p> <p>GData::Client::BadRequestError in 'MyProject::Google::YouTube should upload the actual video to youtube (once it does, mock this test out)' request error 400: No file found in upload request.</p> <p>I am using this code:</p> <p><pre><code> def metadata data = &lt;&lt;-EOF <code>&lt;?xml version="1.0"?&gt; &lt;entry xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:yt="http://gdata.youtube.com/schemas/2007"&gt; &lt;media:group&gt; &lt;media:title type="plain"&gt;Bad Wedding Toast&lt;/media:title&gt; &lt;media:description type="plain"&gt; I gave a bad toast at my friend's wedding. &lt;/media:description&gt; &lt;media:category scheme="http://gdata.youtube.com/schemas/2007/categories.cat"&gt;People&lt;/media:category&gt; &lt;media:keywords&gt;toast, wedding&lt;/media:keywords&gt; &lt;/media:group&gt; &lt;/entry&gt; EOF end</code> <code> @yt = GData::Client::YouTube.new @yt.clientlogin("name", "pass") @yt.developer_key = "myKey" url = "http://uploads.gdata.youtube.com/feeds/api/users/name/uploads" mime_type = "multipart/related" file_path = "sample_upload.mp4" @yt.post_file(url, file_path, mime_type, metadata)</code> </code></pre></p> <p>What is the recommended/standard way for uploading videos to youtube with ruby, what is your method?</p> <h1>Update</h1> <p>After applying the changes to <code>wrapped_entry</code>, the string it produces looks like this:</p> <p><pre><code> <code>--END_OF_PART_59003 Content-Type: application/atom+xml; charset=UTF-8</code> <code>&lt;?xml version="1.0"?&gt; &lt;entry xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:yt="http://gdata.youtube.com/schemas/2007"&gt; &lt;media:group&gt; &lt;media:title type="plain"&gt;Bad Wedding Toast&lt;/media:title&gt; &lt;media:description type="plain"&gt; I gave a bad toast at my friend's wedding. &lt;/media:description&gt; &lt;media:category scheme="http://gdata.youtube.com/schemas/2007/categories.cat"&gt;People&lt;/media:category&gt; &lt;media:keywords&gt;toast, wedding&lt;/media:keywords&gt; &lt;/media:group&gt; &lt;/entry&gt;</code> <code> --END_OF_PART_59003 Content-Type: multipart/related Content-Transfer-Encoding: binary</code> </code></pre></p> <p>... and inspecting the request and response looks like this:</p> <p>Request:</p> <p><pre><code> <code>&lt;GData::HTTP::Request:0x1b8bb44 @method=:post</code> <code>@url="http://uploads.gdata.youtube.com/feeds/api/users/lancejpollard/uploads"</code> <code>@body=#&lt;GData::HTTP::MimeBody:0x1b8c738 @parts=[#&lt;GData::HTTP::MimeBodyString:0x1b8c058</code> <code>@bytes_read=0</code> <code>@string="--END_OF_PART_30909\r\nContent-Type: application/atom+xml; charset=UTF-8\r\n\r\n</code> <code>&lt;?xml version=\"1.0\"?&gt;\n&lt;entry xmlns=\"http://www.w3.org/2005/Atom\"\n xmlns:media=\"http://search.yahoo.com/mrss/\"\n xmlns:yt=\"http://gdata.youtube.com/schemas/2007\"&gt;\n &lt;media:group&gt;\n &lt;media:title type=\"plain\"&gt;Bad Wedding Toast&lt;/media:title&gt;\n &lt;media:description type=\"plain\"&gt;\n I gave a bad toast at my friend's wedding.\n &lt;/media:description&gt;\n &lt;media:category scheme=\"http://gdata.youtube.com/schemas/2007/categories.cat\"&gt;People&lt;/media:category&gt;\n &lt;media:keywords&gt;toast wedding&lt;/media:keywords&gt;\n &lt;/media:group&gt;\n&lt;/entry&gt;</code> <code>\n\r\n--END_OF_PART_30909\r\nContent-Type: multipart/related\r\nContent-Transfer-Encoding: binary\r\n\r\n"&gt;</code> <code>#&lt;File:/Users/Lance/Documents/Development/git/thing/spec/fixtures/sample_upload.mp4&gt;</code> <code>#&lt;GData::HTTP::MimeBodyString:0x1b8c044 @bytes_read=0</code> @string="\r\n--END_OF_PART_30909--">] @current_part=0 @boundary="END_OF_PART_30909"> @headers={"Slug"=>"sample_upload.mp4" "User-Agent"=>"GoogleDataRubyUtil-AnonymousApp" "GData-Version"=>"2" "X-GData-Key"=>"key=AI39si7jkhs_ECjF4unOQz8gpWGSKXgq0KJpm8wywkvBSw4s8oJd5p5vkpvURHBNh-hiYJtoKwQqSfot7KoCkeCE32rNcZqMxA" "Content-Type"=>"multipart/related; boundary=\"END_OF_PART_30909\"" "MIME-Version"=>"1.0"}> </code></pre></p> <p>Response:</p> <p><pre><code> <code>#&lt;GData::HTTP::Response:0x1b897e0 @body="No file found in upload request." @headers={"cache-control"=&gt;"no-cache no-store must-revalidate" "connection"=&gt;"close" "expires"=&gt;"Fri 01 Jan 1990 00:00:00 GMT" "content-type"=&gt;"text/plain; charset=utf-8" "date"=&gt;"Fri 11 Dec 2009 02:10:25 GMT" "server"=&gt;"Upload Server Built on Nov 30 2009 13:21:18 (1259616078)" "x-xss-protection"=&gt;"0" "content-length"=&gt;"32" "pragma"=&gt;"no-cache"} @status_code=400&gt;</code> </code></pre></p> <p>Still not working, I'll have to check it out more with those changes.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload