jprichardson / node-fs-extra

Node.js: extra methods for the fs object like copy(), remove(), mkdirs()
MIT License
9.44k stars 776 forks source link

Endian problem #952

Closed johnbester closed 2 years ago

johnbester commented 2 years ago

I am busy with a project that uses http module to receive requests. I posted a binary file (.deb) as a application/octet-stream body using curl ( curl -POST -H "Content-Encoding: base64" -H "Content-Type: application/octet-stream" --data '@package.deb' 'http://localhost/binary' ). I then used req.on("data") and req.on("end") handlers (where req is instance of http.IncomingMessage) and cast combine the chunks into one UInt8Array to save to disk. When looking at the bytes in the debugger, it corresponds with hexdump -C package.deb. However, when I write out the Uint8Array data to a file and perform a hexdump on it, a 16 bit endian problem switches every two bytes around. I tried it with fs as well as fs-extra (which I assume is only a wrapper) and got exactly the same result.

RyanZim commented 2 years ago

You didn't specify how you're writing the data to disk; in any case, this is clearly not a problem with fs-extra. Closing.