Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6667823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:58:27+00:00 2026-05-26T02:58:27+00:00

I am using this adobe example under reading and writing objects to try and

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:58:27+00:00Added an answer on May 26, 2026 at 2:58 am

    You are using data.writeObject(file);. Those are not random characters, those are serialization markers.

    You aren’t sending an xml document to S3, you are sending a serialized Actionscript XML object (in AMF3 format).

    _bookXml.toXMLString() will give you the xml document as a string. then you should be able to use ByteArray.writeMultiByte() to get what you want. Check out the following example:

        var test:XML = <test><data>Data</data></test>;
    
        var serializeObject:ByteArray = new ByteArray();
        serializeObject.writeObject(test);
        trace(serializeObject.toString());
    
        var rawString:ByteArray = new ByteArray();
        rawString.writeMultiByte(test.toXMLString(), 'utf-8');
        trace(rawString.toString());
    

    The output is:

    �E<test>
      <data>Data</data>
    </test>
    
    <test>
      <data>Data</data>
    </test>
    

    The difference is the first is a serialized object (that you could use .readObject() to deserialize the object out of the byte array back into a XML object in flash). The latter is simply the raw bytes of the string (in utf-8).

    In your case, I would suggest something like this:

    public function uploadObjectToS3(file:Object, objectName:String):void{
        var data:ByteArray = new ByteArray;
        data.writeObject(file);
        data.position = 0;
    
        uploadByteArrayToS3(data, objectName);
    }
    
    public function uploadXmlToS3(file:XML, objectName:String):void{
        var data:ByteArray = new ByteArray;
        data.writeMultiByte(file.toXMLString(), "utf-8");
        data.position = 0;
    
        uploadByteArrayToS3(data, objectName);
    }
    
    private function uploadByteArrayToS3(file:ByteArray, objectName:String):void{
        //code to do s3 upload
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using this xslt file found on this blog to pretty print xml using Nokogiri,
Using this question as the base is there an alogrithm or coding example to
Using this file as source, I have a situation where I need to retrieve
Just using this as an example... Here are the columns in my UserProfile table:
I'm using adobe's example.swf to provide inline flash upgrades for users. However, if the
I'm writing an app for Android using Adobe AIR 3.0 and facebook action script
I'm trying to use Flash's StageVideo object through the example ActionScript file in this
Using this answer , I created a sample localized app. My question is, is
Using this: Can I use Facebook's fb:friend-selector in an iframe? I created a multi-friend
Using this jquery code: <a href=javascript:void(0) id=m1>Get Selected id's</a> jQuery(#m1).click( function() { var s;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.