we are trying to use the Google YouTube API to upload videos from our website to YouTube through the browser directly.
The API works in two steps, in the first step
I would create a form that you display to the user with text fields for the metadata and a file upload control for the video.
Then in the code that handles the postback, you can submit the metadata off to the YouTube API to get the Token Value.
You then craft an HttpWebRequest with the Token Value passed into the Create
method of the WebRequest
object and set the Method
property to Post
. You then add the uploaded video (see dr evil's answer to "Upload files with HTTPWebrequest (multipart/form-data)" for more a walk through of that), and when you call GetResponse()
your file will be submitted.
Things to watch out for:
ScriptTimeout
: If you're allowing your users to upload large files to YouTube - if it takes a while for you to transmit it, then your script could be terminated prematurely.You could post to the YouTube form programatically. I recently modified the example found at http://www.codeproject.com/KB/cs/uploadfileex.aspx to write some code that posted a file to a third party website as a nightly job.
This would involve a performance hit as the file would have to be uploaded to your server and then to YouTube instead of directly to YouTube, but it is an option.
http://code.google.com/apis/youtube/2.0/developers_guide_dotnet.html#Direct_Upload