Questions tagged [arraybuffer]

ArrayBuffer is a Javascript data type used to represent a generic, fixed-length binary data buffer.

597 questions
5
votes
3 answers

Create image from ArrayBuffer in Nodejs

I'm trying to create an image file from chunks of ArrayBuffers. all= fs.createWriteStream("out."+imgtype); for(i=0; i
Yaan
  • 561
  • 1
  • 5
  • 7
5
votes
1 answer

Arraybuffer vs blob performance

Which has better performance? I'm getting data and posting it to a different url, I can send both types but which should I choose? The data is a pdf file
user59388
  • 159
  • 1
  • 10
5
votes
2 answers

JSON.stringify or how to serialize binary data as base64 encoded JSON?

I have a Javascript object which will consists of a non-cyclic object hierarchy with parameters and child objects. Some of these objects may hold binary data loaded from files or received via XHRs (not defined yet if Blob, ArrayBuffer or something…
Sebastian Barth
  • 4,079
  • 7
  • 40
  • 59
5
votes
0 answers

non-HTML5 browsers send raw file content with XMLHttpRequest

Is there a way to read the raw file content of the file and send the binary data to the server with an XMLHttpRequest ajax request? In HTML5 browsers I can do this: reader = new FileReader(); reader.readAsArrayBuffer(file); reader.onload =…
danial
  • 4,058
  • 2
  • 32
  • 39
5
votes
1 answer

Send ArrayBuffer with other string in one Ajax call through jQuery

I'm working on a project need to upload large file to server side. I decided to use HTML5 FileReader and jQuery to upload the file in chunks (ArrayBuffer). I successfully finished this task by converting the chunks into base64 string, send to…
Shaun Xu
  • 4,476
  • 2
  • 27
  • 41
5
votes
0 answers

how to serialize ArrayBuffer into BSON object for websocket transfer in javascript

I want encode a javascript object with a ArrayBuffer element into BSON and transfer it over websocket. However the serialized BSON object is 10 time bigger than it should be. The code is something like this: var A = {buffer: new…
J.C. Li
  • 141
  • 2
  • 4
5
votes
3 answers

How do I load a binary file during javascript unit test?

In my application, the user uses HTML5 drag and drop to process a binary file. That part of the code works fine. In chrome, I drag a binary file and use a FileReader to create an arrayBuffer. That all seems to work fine. I am writing tests for…
pgreen2
  • 3,601
  • 3
  • 32
  • 59
4
votes
3 answers

strange ArrayBuffer behavior

Can someone please explain to me why the padTo method of ArrayBuffer doesn't work as I would expect it to? In this example, I would expect the array created by toArray to have a length of 10. scala> val b = new…
Kim Stebel
  • 41,826
  • 12
  • 125
  • 142
4
votes
0 answers

How can I post binary data in browsers that don't support Typed Arrays

I'm trying to post binary data to a server. This works exactly as I need it, in Chrome 15: XMLHttpRequest.prototype.sendAsBinary = function(datastr) { function byteValue(x) { return x.charCodeAt(0) & 0xff; } var ords =…
wildabeast
  • 1,723
  • 3
  • 18
  • 31
4
votes
2 answers

Web scraping in Python - Arraybuffer to data readable

I'm developing a web scraper for the Hoymiles monitoring system. One of the statistics I can get is historical data, but I get data in a strange format. After a lot of research and a search in the platform code, I found that in the post request made…
4
votes
3 answers

How to encode integer to Uint8Array and back to integer in JavaScript?

I need to add compression to my project and I decided to use the LZJB algorithm that is fast and the code is small. Found this library https://github.com/copy/jslzjb-k But the API is not very nice because to decompress the file you need input buffer…
jcubic
  • 61,973
  • 54
  • 229
  • 402
4
votes
1 answer

JavaScript converting audio byte array to wav file or valid AudioBuffer

I have access to a byte array file (float32, big endian) from a URL, and I'm trying to convert it into something processable by WaveSurfer, which needs a valid ArrayBuffer, AudioBuffer, or a URL to a wav file. The closest I've gotten is using fetch…
thedavl
  • 183
  • 1
  • 9
4
votes
2 answers

Displaying PNG image in ArrayBuffer in React

I am trying to get an image (PNG format) to display in a React app after making a JavaScript call. The code is as follows. The function DeviceService.getFile returns the file in a blob. The data is binary. How can I get this image to be displayed…
Eugene
  • 1,013
  • 1
  • 22
  • 43
4
votes
1 answer

How to cast an `ArrayBuffer` to a `SharedArrayBuffer` in Javascript?

Take the following snippet: const arr = [1.1, 2.2, 3.3] const arrBuffer = (Float32Array.from(arr)).buffer How would one cast this ArrayBuffer to a SharedArrayBuffer? const sharedArrBuffer = ...?
Tom
  • 8,536
  • 31
  • 133
  • 232
4
votes
1 answer

Buffer from ArrayBuffer with memory copy

I'm switching from Node.js 8.X to Node.js 10.x and I'm getting some deprecated warnings on "new Buffer" I have an arrayBuffer that I need to copy into a Buffer and my first version was like this: const newBuffer = Buffer.from(myArrayBuffer) But the…
Nico AD
  • 1,657
  • 4
  • 31
  • 51