YouTube API integration ASP.NET - upload video with a single page

后端 未结 3 907
名媛妹妹
名媛妹妹 2020-12-16 05:52

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

相关标签:
3条回答
  • 2020-12-16 06:33

    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:

    1. 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.
    2. Bandwidth: You'll have both the upload to your servers and then the upload to YouTube to account for - by allowing the user to upload directly to YouTube in a two step process you never touch the video, and it never goes near your servers - this might be an issue for you or your hosting provider - for example, my host doesn't count traffic through FTP in my monthly bandwidth, but does include files uploaded/downloaded through the website.
    0 讨论(0)
  • 2020-12-16 06:39

    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.

    0 讨论(0)
  • 2020-12-16 06:40

    http://code.google.com/apis/youtube/2.0/developers_guide_dotnet.html#Direct_Upload

    0 讨论(0)
提交回复
热议问题