0 Replies Latest reply on Aug 12, 2010 10:12 AM by j.ochoa

    How can I read a binary file?

    j.ochoa

      In my AIR application, I'm trying to read a binary file and then post it via an HTTPService to a remote ColdFusion component that accepts a "binary" type argument.  The result of the post is always:

       

      The FILEOBJ argument passed to the addFile function is not of type binary.

       

      Here is how I'm reading the file in Flex, where fileObj is of type File:

       

      var fs : FileStream = new FileStream();

      var bytes : ByteArray = new ByteArray();

       

      fs.open(fileObj, FileMode.READ);

      fs.readBytes(bytes, 0, fs.bytesAvailable);

      fs.close();

       

      I then pass "bytes" as the parameter to my HTTPService's send call, like so:

       

      var params : Object = {method : "addFile", fileObject : bytes};

      service.send(params);

       

      When I debug, bytes contains the correct file size.  Is it not in binary form?  I've tried several other suggestions, but with the same result, so would appreciate any help.

       

      Thanks!