YouTube Direct Upload in ActionScript3

 

An app I wrote needed the following features:

  1. Application has to run in the browser as a SWF.
  2. Application will run in filesystem mode (file://).
  3. Application will not have server side (except for YouTube).
  4. Application will have to login to YouTube using ClientLogin instead of AuthSub to avoid redirects.
  5. Application will have to upload a manipulated ByteArray, not directly from FileReference.browse().
First thing you do: Search Google for YouTube+Upload+ActionScript, which brings up many results, including this library.
Unfortunately, none of the results presented a solution to the above, and surprisingly, the AS3 DataAPI library doesn’t even implement an upload API.
A few other search queries… no results.

So, I turned to the YouTube API docs, looked at the PHP implementations and the result is this class which I’m sharing with you now.

Introducing: YouTubeDirectUploader.as – A utility class for uploading to YouTube using email and password.

The class provides two methods of uploading:

  1. Using FileReference and browse() – which will opt the user to select their video to upload.
  2. Using a ByteArray – which allows the Application to manipulate the FLV before uploading to YouTube (what was needed in my case).

It was also designed to be used as a declared object in MXML, just to ease the use and allow bindings to form elements.

Check/Fork the code on GitHub. Share your thoughts below : )