Write Bytes server side with File class
Hi there,
Does anyone knows if it's possible to write some bytes received from an AIR or Flex client in a server side file using the File class ? I have been trying for hours without any result.
My goal is to store on the server side a swf file sended by a client in a ByateArray.
Here is the code I have ended with, assuming that myfile.swf alreadey exists on the server prior to the code execution, and is at the right place, and that pBytes is a ByteArray received from the client which contains a swf file :
function writeFile( pBytes )
{
var myFile = new File( "myFile.swf" );
if( myFile.open( "binary", "write" ) )
{
for( var i = 0; i < pBytes.length; i++ )
{
myFile.writeByte( pBytes );
myFile.seek( i );
}
}
myFile.flush();
myFile.close();
}
Before using the for loop I tried writeAll() and write() methods without success. FMS won't record the bytes in the file and, an error is raised :
Sending error message: C:\Program Files\Adobe\Flash Media Server 3.5\applications\_convexe2009\main.asc: line 114: File operation writeByte failed.
Does anyone have any idea of what's happening here ?
I would really appreciate any help on this, because this is driving me nuts !
Txhs
