Remember that binary is just encoded data. This is less a JavaScript question and more an encoding question. Here's how I would do it.
Set aside 32 bits (representing one integer) at the beginning of your request to specify the bit length of test.dat. Then combine this with your two data sources. Your payload will look like this:
TEXT_LENGTH + TEST.DAT AS BINARY + FILECONTENT AS BINARY
Then get back the data as an array buffer. Use
textLengthBits = parseInt(arrBuffer.slice(0,32), 2);
To get the length of the text. Then slice again,
textBits = arrBuffer.slice(32, 32 + textLengthBits)
To get the text. The remaining bits are your file.
fileBits = arrBuffer.slice(32 + textLengthBits);
JSON.stringifyusemsgpack.encode.