public
Description: Flex uploader for Panda
Homepage: http://pandastream.com
Clone URL: git://github.com/newbamboo/panda_flex_uploader.git
dctanner (author)
Mon Mar 30 03:53:23 -0700 2009
commit  fb3266e188c176faea0b2b90d6933472ab6714c9
tree    3a2af1f6f3458994cf36bb5b05a64835e6d3520c
parent  ccc38931ffbc6e4168bdd1c75b957c791a7c8461
name age message
file .DS_Store Loading commit data...
file README.markdown
directory bin-debug/
directory bin-release/
directory html-template/
directory src/
README.markdown

Flex uploader for Panda

Before beginning you will need to have Panda setup and running on your server or an EC2 instance. See http://pandastream.com/docs/ for details about how to do this.

To use the Flex uploader you will will first need to make a POST request to the API of your Panda install, to obtain an upload token. When making this request you include your API key (set when you installed Panda) so the upload can be authenticated. In the response of the POST request you will get an ID for the video which is passed to the Flex uploader and used to identify the upload.

If you're using Ruby on Rails for your client application, you can use the Panda ruby library. See Integrating Panda with your Ruby on Rails application for details. The example Rails Panda client includes an example of the Flex uploader in use.

If you're using PHP, there is a useful library for consuming REST APIs called HTTP_Request2.

Using the uploader

The src/panda_uploader.mxml file contains the bulk of the uploader. If you open the project up in Flex Builder and run Project -> Export Release Build. Copy the bin-release/panda_uploader.swf file to your client application (the public/ folder if you're using Rails).

When a user creates a new video in your client application, you will need to make the POST request to Panda to get an ID for the video. Details of making the request are covered in the API Documentation.

You will then want to display the Flex uploader to the user by embedding it. Take special note of the uploadDest flashVar which is set.

<object id="main" width="500" height="100"
    codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
    <param name="movie" value="/panda_uploader.swf" />
    <param name="quality" value="high" />
    <param name="bgcolor" value="#ffffff" />
    <param name="allowScriptAccess" value="sameDomain" />
    <param name="flashVars" value="uploadDest=UPLOAD_DEST" />
    <embed src="/panda_uploader.swf" quality="high" bgcolor="#ffffff"
      flashVars="uploadDest=UPLOAD_DEST"
        width="500" height="100" name="main" align="middle"
        play="true"
        loop="false"
        quality="high"
        allowScriptAccess="sameDomain"
        type="application/x-shockwave-flash"
        pluginspage="http://www.adobe.com/go/getflashplayer">
    </embed>
</object>

The UPLOAD_DEST text will need to be dynamically replaced with the upload url for that video. The url is built like so:

http://ADDRESS_OF_PANDA_EC2_INSTANCE/videos/VIDEO_ID_FROM_POST_REQUEST/upload

When the user chooses a file it will be immediately uploaded to Panda and added to the encoding queue just as a normal upload is.