Quantcast
Channel: Adobe Community : Popular Discussions - Archived Discussions
Viewing all articles
Browse latest Browse all 21156

Decode Base64 and save as binary file

$
0
0

Hi there,

 

I am using Adobe Air 1.5 with JavaScript and want to save a file to my hard

drive. I get the data from a WebService via SOAP as a Base64 encoded string. A test-string is attached. When I try to decode it with

the WebKit function "atob()" and try to save this bytes with following code, I can't open the file.

 

this.writeFile = function(outputfile, content, append){

var file =a ir.File.applicationStorageDirectory.resolvePath(outputfile);

var stream = newa ir.FileStream();

 

if (append) {

stream.open(filea, ir.FileMode.APPEND);

}else {

stream.open(filea, ir.FileMode.WRITE);

}

 

try{//Binärdaten

stream.writeBytes(content0, , content.length);

}catch(e){//Textdaten

stream.writeUTFBytes(content);

}

 

stream.close();

};

 

The same happens when I try to open a file from my HDD and read in the bytes. When I decode it to base64, the string is not equal to the string, which is correct.

I attached a working Base64 string, which I could convert back to a zip-file via a only encoder.

 

So my question is, how can I decode a Base64 string and save the binary data to a file?

 

Thank you for your help.


Viewing all articles
Browse latest Browse all 21156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>