using writeFile to write binary data
Posted: 06 Oct 2010, 18:21
Hi there,
I got a tricky one here:
I'm trying to create a jpg file in the server by using the _server.writeFile.
I'm converting the ByteArray to Base64 on the client, sending it via JSON to the server, then converting it back to binary by decoding it.
The Base64 string is working just fine and I tested several times, but the problem is when I write the decoded string into a file. The file always get corrupted.
Here is a website you can test it out:
http://decodebase64.com/ (use the example provided in the first comment)
If you try to decode that exact string into bytes and write it to a jpg file, it comes out corrupted.
I got a tricky one here:
I'm trying to create a jpg file in the server by using the _server.writeFile.
I'm converting the ByteArray to Base64 on the client, sending it via JSON to the server, then converting it back to binary by decoding it.
Code: Select all
_server.writeFile("c:\\test64.jpg", decode64(params.im));Here is a website you can test it out:
http://decodebase64.com/ (use the example provided in the first comment)
If you try to decode that exact string into bytes and write it to a jpg file, it comes out corrupted.