0 Replies Latest reply on Feb 15, 2011 3:10 AM by chriswyl

    how send binary data via HTTPService

    chriswyl

      Hi,

       

      I have a serious problem with sending binary data.

       

      Unfortunately I have not done server side and  I need to adjust

       

      I show you simple code.

       

      In appclication i've button  click="tosend()";

       

      private function tosend() : void
                  {
                      var tim:Timer = new Timer(1000,1);
                      tim.addEventListener(TimerEvent.TIMER_COMPLETE, compl);
                      tim.start();
                  }

       

      private function compl(e:TimerEvent) : void
                  {
                    var  byteData : ByteArray = (here bytes from jpg encoder example);

       

                     var urlRequest : URLRequest = new URLRequest();
                      urlRequest.url = 'http://mydomain..../gateway.rxml';
                      urlRequest.contentType = 'multipart/form-data; boundary=' + UploadPostHelper.getBoundary();
                      urlRequest.method = URLRequestMethod.POST;
                     
                      var byte:ByteArray = UploadPostHelper.getPostData( 'image.jpg', byteData,'',param );
                      urlRequest.data = UploadPostHelper.getPostData( 'image.jpg', byteData,'',param ); // in this place a use Class return binarydata (ByteArray)
                      urlRequest.requestHeaders.push( new URLRequestHeader( 'Cache-Control', 'no-cache' ) );
                     
                      // create the image loader & send the image to the server;
                      var urlLoader : URLLoader = new URLLoader();
                      urlLoader.dataFormat = URLLoaderDataFormat.BINARY;

                      urlLoader.load( urlRequest );

                }

       

      When application launched I see (SecurityError: Error #2176:),  Of course when i fired this without timer it working .I know but is there another way? -

       

      I tryed another way. I used HTTPService and before sending data  I convert it to Base64, - it working but, It not be welcome.

       

      I can not use RemoteObject or NetConnection (AMF).