apache-fleximageactionscriptserver-communication

Flex sending snapshot without using base64Encode


var is:ImageSnapshot = myImagesnapshot;
var str:String = ImageSnapshot.encodeImageAsBase64(is);

As of now, I am sending my jpeg data to the server with the code above.
The problem is that it almost doubles the size of the data.
Is there a way to send the image data directly without using any encoding.


Solution

  • Here is a sample of sending image data without using Base64 :

     var myEncoder:JPGEncoder = new JPGEncoder(100);
     var byteArray:ByteArray = myEncoder.encode(bitmapData);
     var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
        var url:String = "../../default.php";
        var saveJPG:URLRequest = new URLRequest(url);
        saveJPG.requestHeaders.push(header);
        saveJPG.method = URLRequestMethod.POST;
        saveJPG.data = byteArray;
    

    On PHP side, I need to access :

     $globalS["HTTP_raw_post_data"]