Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
35
rated 0 times [  38] [ 3]  / answers: 1 / hits: 18192  / 8 Years ago, fri, march 25, 2016, 12:00:00

I'm trying to create an image file from chunks of ArrayBuffers.



all= fs.createWriteStream(out.+imgtype);

for(i=0; i<end; i++){
all.write(picarray[i]);
}

all.end();


where picarray contains ArrayBuffer chunks. However, I get the error
TypeError: Invalid non-string/buffer chunk.


How can I convert ArrayBuffer chunks into an image?


More From » node.js

 Answers
1

Have you tried first converting it into a node.js. Buffer? (this is the native node.js Buffer interface, whereas ArrayBuffer is the interface for the browser and not completely supported for node.js write operations).



Something along the line of this should help:



all= fs.createWriteStream(out.+imgtype);

for(i=0; i<end; i++){
var buffer = new Buffer( new Uint8Array(picarray[i]) );
all.write(buffer);
}
all.end();

[#62807] Wednesday, March 23, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
patienceannel

Total Points: 674
Total Questions: 101
Total Answers: 101

Location: Northern Mariana Islands
Member since Fri, Jan 15, 2021
3 Years ago
patienceannel questions
Fri, Mar 11, 22, 00:00, 2 Years ago
Tue, Oct 20, 20, 00:00, 4 Years ago
Wed, Jul 24, 19, 00:00, 5 Years ago
;