1 Reply Latest reply on Nov 4, 2011 8:31 AM by drkstr_1

    Upload Chunks of File to Remote Server AIR ???

    Mitul Golakiya

      Hi,

       

      I am trying to make one sample uploader application that will sends some chunks of file data to remote server continually.

      I will call one php file which will be on remote server and which will also demand for some other variables like chunkId and totalchunks.

       

      I am using socket to do that but I can post the data to the server.

      How can I send variable with socket data ?

      How can I use chunk mechanism with socket ???

       

       

      Pls help me....

        • 1. Re: Upload Chunks of File to Remote Server AIR ???
          drkstr_1 Level 4

          I would actually recommend using an AMF service rather than sockects (there is Zend_AMF for PHP) to easily send your chunk data in a typed Value Object (or DTO if you prefer).

           

          You can use the readBytes method of a ByteArray to break your file up into chunks.

           

          More info here: http://help.adobe.com/en_US/air/html/dev/WS5b3ccc516d4fbf351e63e3d118666ade46-7d54.html

           

          Then just assign the resulting ByteArray as a property to a class that contains your other variable data. This class can then be sent over a binary AMF connect, and read in server side as a typed PHP class with the same properties and daa.

           

          Here are some basics on using Zend_AMF: https://www.adobe.com/devnet/flex/articles/crud_flex_php_zend.html

           

          If this isn't possible for one reason or another, you can always add some additional variables to your file chunk data before you send it over the socket, then extract them server side. Or, call a basic web service before creating the socket connection, and send all the needed variables with that call. The web service can return a token used in creating the sockect connection that ties the incoming binary data with the correct record created from the web service call.