I upload a file using adobe air HTTPService.Send method by passing byte array of file content read using FileReference. When I write the set of bytes from the server side (php) it writes the details of the byte array (buff) to the file instead of contents of the file like "endian=bigEndian&position=0&bytesAvailable=61127&length=61127&objectEncoding=3" . Below I have included the code that how I read the file and send it to server. Is there anyway that i can directly pass the data in the byte array to send method?
File Read
var buff:ByteArray = new ByteArray();
var localFilePath:String = "/Videos/sample.txt";
var uploadedFile:File = new File(localFilePath);
var uploadedFileStream:FileStream = new FileStream();
uploadedFileStream.open(uploadedFile,FileMode.READ);
uploadedFileStream.readBytes(buff);
uploadedFileStream.close();
File upload
var serverPath:String = "http://myurl.com/rests";
var service:mx.rpc.http.mxml.HTTPService=new mx.rpc.http.mxml.HTTPService();
service.url=serverPath;
service.requestTimeout=30;
service.method="POST";
service.contentType="application/x-www-form-urlencoded";
service.addEventListener(ResultEvent.RESULT,onResponceReceive);
service.addEventListener(FaultEvent.FAULT,onResponceFail);
var userName:String="myusername";
var password:String="mypwd";
var encoder:Base64Encoder = new Base64Encoder();
encoder.insertNewLines=false;
encoder.encode(userName+":"+password);
service.headers={Authorization:"Basic "+encoder.toString()};
try{
service.send(buff);
}catch(error:Error){
Alert.show(error.message);
}