Question

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.

Was it helpful?

Solution 2

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"]

OTHER TIPS

base64 increases size by a third, so if you really have about 100% overhead, you have a problem elsewhere.

haven't looked at the sources to well, but from the reference it seems, you could retrieve the binary data directly.

just tuck that into a URLRequest and send it per POST.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top