javascript - convert bytes array to blob (uint8 array to blob)
JavaScript[Edit]
+
0
-
0
JavaScript - convert bytes array to Blob (UInt8 array to Blob)
1 2 3 4 5 6 7 8const array = [82, 73, 70, 70, 26, 0, 0, 0, 87, 69, 66, 80, 86, 80, 56, 76, 13, 0, 0, 0, 47, 0, 0, 0, 16, 7, 16, 17, 17, 136, 136, 254, 7, 0]; const options = { type: 'image/webp' // change 'image/webp' depending on bytes in array }; const chunks = [new Uint8Array(array)]; const blob = new Blob(chunks, options);
[Edit]
+
0
-
0
javascript - convert bytes array to blob (uint8 array to blob)
1 2 3const array = [82, 73, 70, 70, 26, 0, 0, 0, 87, 69, 66, 80, 86, 80, 56, 76, 13, 0, 0, 0, 47, 0, 0, 0, 16, 7, 16, 17, 17, 136, 136, 254, 7, 0]; const blob = new Blob([new Uint8Array(array)], {type: 'image/webp'}); // change 'image/webp' depending on bytes in array