S
S
sirinotapple2022-03-18 12:02:49
Node.js
sirinotapple, 2022-03-18 12:02:49

How to pass fileReader.readAsBinaryString?

Hello,
I am transferring binaryString from the client to the server, but it seems that the encoding is recognized differently on the server, for example, after reader.readAsBinaryString on the client it will be PK???!?bîh^?????[Content_Types].xml
and on the server already
âÁ(Ú+þº ö "C b ¶v¯vµ3µW^ oBBëÌ$Q·ªU ס?jë¬ÀÂÉåVÛõ½ì
although in the vscode debugger the encoding is recognized correctly.
It also works correctly with the text, but with the contents of the file there
is nothing. What goes wrong. ..

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GrayHorse, 2022-03-18
@sirinotapple

const file = e.target.files[0];
const ab = await file.arrayBuffer();
WebSocket.send(ab);
const workbook = XLSX.read(ab, {
    type: "buffer"
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question