0 Replies Latest reply on Jan 12, 2012 7:32 AM by RandomReado

    Upload video using Flex/AIR

    RandomReado Level 1

      I need to upload a large video using Flex/AIR but I'm having trouble doing so. First I thought about doing the following:

       

      <?xml version="1.0" encoding="utf-8"?>

      <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"

                             xmlns:s="library://ns.adobe.com/flex/spark"

                             xmlns:mx="library://ns.adobe.com/flex/mx"

                             creationComplete="upload()">

          <fx:Script>

              <![CDATA[

                  import mx.rpc.events.ResultEvent;

                 

                  private function upload():void

                  {

                      var fl:File = File.desktopDirectory.resolvePath('S1000001.MP4');

                      var fs:FileStream = new FileStream();

                      fs.open(fl, FileMode.READ);

                      var ba:ByteArray = new ByteArray();

                      fs.readBytes(ba);

                      fs.close();

                     

                      remoteObject.upload(ba);

                  }

                 

                  private function uploadResult(e:ResultEvent):void

                  {

                     

                  }

              ]]>

          </fx:Script>

          <fx:Declarations>

              <s:RemoteObject id="remoteObject"

                              source="Test"

                              destination="zend">

                  <s:method name="upload" result="uploadResult(event)"/>

              </s:RemoteObject>

          </fx:Declarations>

      </s:WindowedApplication>

       

      Essentially this is automatically picking up the video "S1000001.MP4" on my desktop, converting into a ByteArray and sending via AMF to the PHP server. However the ByteArray process causes the runtime memory usage to exceed the limits, and eventually the runtime crashes. The video is only 350MB.

       

      Rather than putting the video into a ByteArray, is it not possible to simply stream the video as a ByteArray to the server?