When I save an Xml with FileReference.save(), 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 :
</test>NUL NUL NUL NUL NUL NUL NUL NUL NUL
This is an old problem of FileReference.save() 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:
var path = defaultPath != null ? Path.withoutDirectory(defaultPath) : "download" + defaultExtension; var buffer = (data : Bytes).getData();
buffer = buffer.slice(0, (data:Bytes).length);
Thanks for your feedback.
Do you think I can pass my own ByteArray in
FileReference.save() instead of using a String to avoid modifying
EDIT : Well, no I can’t do that. It seems that modifying
FileDialog.hx like you suggest is the only way.
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!