Hi,
I have a small problem with the following code which aims to download a
binary file from a server ans save it to the virtual FS with the
FS.writeFile. No matter what I try the file doesn't get written, so perhaps
I am doing something substancially wrong. Can anyone provide a hint what I
need to correct?
JS code:
xhr = new XMLHttpRequest();
xhr.open("GET", "dtest", true);
xhr.responseType = "arraybuffer";
xhr.overrideMimeType("application/octet-stream");
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
console.log(xhr.response);
blob = new Blob([new Uint8Array(xhr.response)], {type
: "application/octet-stream"});
console.log(blob);
FS.writeFile('/dtest', [blob], { encoding: "binary"
});
console.log('dtest: '+(FS.stat('/dtest')).size);
refreshSGList();
}
};
xhr.send();
>From the console output I guess that the download from the file is working,
the size is the expected:
ArrayBuffer { byteLength: 11667 }
Blob { size: 11667, type: "application/octet-stream" }
"dtest: 1"
But the size that is reported back from FS.stat is wrong and the file is
unusable, so I think it is not written eventually.
I am using this with emscripten sdk 1.25 on OSX 10.8.5.
Many thanks for your help!
Stefan
--
You received this message because you are subscribed to the Google Groups
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.