Copy link to clipboard
Copied
The image is taken as photo from the CameraUI in the Client Side(AIR Mobile Application) and saved as a .jpg file in the mobile. I passed the image byte array values from the client to the server. How to convert that byte array to a file in the Adobe Media server?
Copy link to clipboard
Copied
You can use File class to write bytearray to a file. For more details about the same, check the following link:
Copy link to clipboard
Copied
private function imageLoading():void
{
var req:URLRequest = new URLRequest(image file url path);
var urlLoader:URLLoader = new URLLoader(req);
urlLoader.addEventListener(Event.COMPLETE, onURLLoaderComplete);
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
urlLoader.load(req);
}
private function onURLLoaderComplete(event:Event):void
{
imageByteArray = event.target.data;
}
This imageByteArray is passed to the Server. Server received this bytearray as an Object. How to get the raw bytearray data from this object in Server side?
Copy link to clipboard
Copied
You can use NetConnection.call method and pass ByteArray as one of the arguments. For more details about NetConnection.call(), check the link http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetConnection.html#call...
Also, In the server side you can create a ByteArray object and call ByteArray.writeBytes() method to write the data to server side ByteArray or else you can directly write the ByteArray to a file in binary mode. For more details about ByteArray class see:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/utils/ByteArray.html
Copy link to clipboard
Copied
This is very similar to the problem here:
http://forums.adobe.com/thread/655314
processByteArray = function(byteArrayAsPlainObject){
// byteArrayAsPlainObject is an object serialized from a ByteArray but without functions
// we need to get a ByteArray that we can call functions on
var usableByteArray = new ByteArray();
byteArrayAsPlainObject.position = 0; // make sure we start from the beginning
ByteArray.prototype.readBytes.call(byteArrayAsPlainObject, usableByteArray);
// now usableByteArray contains what was in the original argument, but we can actually use it on the server side
}