I am using this adobe example under "reading and writing objects" to try and convert an XML file to a byteArray and save the file somewhere. I use this to upload the file to s3. When i download the XML file with s3 i get 4 random characters in front of the XML file. Looking into the issue [example of what i think is happening], it seems that the extra characters are being created with the encoding scheme. However, adobes example uses writeObject to convert an XML to a byteArray, so I don't see how i am using the incorrect encoding scheme.
my code is fairly simple.
creating the byteArray:
var _bookXml:XML = _book.serialize(); //converts book to XML
var photobookXmlName:String = photobookToken + "_layout.xml";
_s3uploader.uploadObjectToS3(_bookXml, photobookXmlName); //uploads XML
and the uploadObjectToS3 code:
public function uploadObjectToS3(file:Object, objectName:String):void{
var data:ByteArray = new ByteArray;
data.writeObject(file);
data.position = 0;
//code to do s3 upload
}
heres a before/after example XML file i used as a test case:
before:
<xml>
<test>data</test>
</xml>
after:
��5<xml>
<test>data</test>
</xml>
any idea how to fix this issue so I dont get random characters? I've tried a few things but they didn't work.
thanks
edit: before anyone suggests, i already trtied changing the uploadObjectToS3 input form an object to a ByteArray. It didnt change anything.