Problem with

When I save an Xml with, the file is downloaded in my computer. The Xml is written in the file but there are additional data at the end like this, so the file is not a valid xml. I’ve tested only on html5.
Sample file :

1 Like

This is an old problem of in HTML5. I ran into a situation where I needed to save binary data to a file (level data), and the presence of garbage at the end of the file was critical for me.
For some reason I am currently using openfl 8.9.1 (lime 7.4.0), so the code may not match. In my case, problem resolved by adding string:
file: lime/ui/FileDialog.hx,
function: save,
var path = defaultPath != null ? Path.withoutDirectory(defaultPath) : "download" + defaultExtension; var buffer = (data : Bytes).getData();
new string:
buffer = buffer.slice(0, (data:Bytes).length);

1 Like

Thanks for your feedback.
Do you think I can pass my own ByteArray in instead of using a String to avoid modifying FileDialog.hx?

EDIT : Well, no I can’t do that. It seems that modifying FileDialog.hx like you suggest is the only way.

Here is the PR
Thanks @Egis

This buffer.slice() looks like bad & ugly hack. It would be better to find and fix memory corruption…

Yep. But I prefer something usable now than waiting too long or never get any fix.

It would be great if you share your fix with us!