Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

file.arrayBuffer() in pop()'s reception

I would like to be able to send a binary file from the device to the companion and receive it correctly. when I receive the file with pop() and try to retrieve the contents with file.arrayBuffer(), I get [object ArrayBuffer] and cannot see the contents. Is the payload correctly receiving the file when it outputs [object ArrayBuffer]? When I receive it with text(), nothing is displayed.

 

I look forward to working with you.

 

The program is shown below.

 

 

 

 

let file;
while ((file = await inbox.pop())) {
//console.log(`file contents`);
console.log(`Received File: <${file.name}>`);
const payload = await file.arrayBuffer();
console.log(`file contents: ${payload}`);
}

 

 

output↓

Received File: <filename.bin>
file contents:  [object ArrayBuffer]

 

Best Answer
0 Votes
2 REPLIES 2

It may not be valid to try to display the contents of an ArrayBuffer like that. For a start, javascript doesn't know what types of values are in the array.

Try creating a typed array of the correct type. You may need to iterate through it to see its contents.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

Thank you very much.

Best Answer
0 Votes