arraybuffer

Migrate FileReader ReadAsBinaryString() to ReadAsArrayBuffer() or ReadAsText()

匆匆过客 提交于 2019-12-11 16:55:12
问题 I realize that the new Mozilla Firefox return allocation size overflow (on FileReader.ReadAsBinaryString()) when the file bigger than 200MB (something like that). Here's some of my code on test for client web browser: function upload(fileInputId, fileIndex) { var file = document.getElementById(fileInputId).files[fileIndex]; var blob; var reader = new FileReader(); reader.readAsBinaryString(file); reader.onloadend = function(evt) { xhr = new XMLHttpRequest(); xhr.open("POST", "upload.php",

FileReader readAsArrayBuffer in IE11 not working for large files

只愿长相守 提交于 2019-12-11 16:21:23
问题 I have used filereader object to convert file to arraybuffer. In IE11 it is working fine for max 20mb files. but not working for 200mb file and it results null instead array buffer value. Below mentioned my code var fr = new FileReader(); //reads in the file using the fileReader HTML5 API (as an ArrayBuffer) - readAsBinaryString is not available in IE! fr.readAsArrayBuffer(file); fr.onload = (evt:any) => { console.log(evt.target.result);// it returns only null for 200mb file } Valuable

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

♀尐吖头ヾ 提交于 2019-12-10 17:23:52
问题 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 else). Normally I would use JSON.stringify() to serialize it as JSON but how can I then specify that binary data will be base64 encoded? What binary data object (Blob, ArrayBuffer,...) would you recommend me then? EDIT: Other data formats than plain

HTML5 Audio API inputBuffer.getChannelData to audio Array buffer

北慕城南 提交于 2019-12-10 11:01:50
问题 I am making an application where I am taking mic data from the inputBuffer and I want to stream to another client and play it. However, I cannot get it wokring. My recording/capturing works fine so I will skip to relevant parts of the code function recorderProcess(e) { var left = e.inputBuffer.getChannelData(0); var convert = convertFloat32ToInt16(left); window.stream.write(convert); var src = window.URL.createObjectURL(lcm); playsound(convert); ss(socket).emit('file',convert, {size: src.size

Transmitting an ArrayBuffer with metadata (over a webRTC data connection)

寵の児 提交于 2019-12-08 11:20:34
In docs, I see the following example for sending a string over a WebRTC data channel: var message = messageInputBox.value; sendChannel.send(message); I'm trying to send images and video - so I create an ArrayBuffer : var reader = new FileReader(); reader.addEventListener("loadend", function () { // reader.result contains the contents of blob as a typed array data.media = reader.result; // ArrayBuffer outboundMediaQueue.push(data); }); reader.readAsArrayBuffer(data.media); I can transmit this ArrayBuffer, but I'm trying to also send some metadata alongside it (media ID). Given that I can't JSON

how to convert arraybuffer to string

早过忘川 提交于 2019-12-08 05:48:42
问题 I have written a simple TCP server on node.js to send some data to a Chrome app. In the chrome app, when I get the data, I convert that to string using below function, I get an exception " byte length of Uint16Array should be a multiple of 2 " String.fromCharCode.apply(null, new Uint16Array(buffer)) I could not find any information about what could be causing this and how to fix this. Any pointers on this is highly appreciated. Below is the code in node.js server for sending the data to

Transmitting an ArrayBuffer with metadata (over a webRTC data connection)

孤街醉人 提交于 2019-12-08 05:45:48
问题 In docs, I see the following example for sending a string over a WebRTC data channel: var message = messageInputBox.value; sendChannel.send(message); I'm trying to send images and video - so I create an ArrayBuffer : var reader = new FileReader(); reader.addEventListener("loadend", function () { // reader.result contains the contents of blob as a typed array data.media = reader.result; // ArrayBuffer outboundMediaQueue.push(data); }); reader.readAsArrayBuffer(data.media); I can transmit this

NodeJS stream pausing/resuming does not work with XMLHttpRequest, but works with curl?

独自空忆成欢 提交于 2019-12-08 02:04:53
问题 This is a pretty esoteric issue that I can't produce a small test case for, so sorry in advance. But maybe someone has run into something like it previously. I have code like this (using restify): server.put("/whatever", function (serverRequest, serverResponse, next) { serverRequest.pause(); serverRequest.on("data", function (chunk) { console.log("from outside", chunk); }); doSomeAsyncStuff(function (err) { serverRequest.on("data", function (chunk) { console.log("from inside", chunk); });

How to Convert UTF8 ArrayBuffer to UTF16 JavaScript String

你离开我真会死。 提交于 2019-12-08 00:32:46
问题 The answers from here got me started on how to use the ArrayBuffer: Converting between strings and ArrayBuffers However, they have quite a bit of different approaches. The main one is this: function ab2str(buf) { return String.fromCharCode.apply(null, new Uint16Array(buf)); } function str2ab(str) { var buf = new ArrayBuffer(str.length*2); // 2 bytes for each char var bufView = new Uint16Array(buf); for (var i=0, strLen=str.length; i<strLen; i++) { bufView[i] = str.charCodeAt(i); } return buf;

scala集合类详解

不打扰是莪最后的温柔 提交于 2019-12-07 19:07:19
对scala中的集合类虽然有使用,但是一直处于一知半解的状态。尤其是与java中各种集合类的混合使用,虽然用过很多次,但是一直也没有做比较深入的了解与分析。正好趁着最近项目的需要,加上稍微有点时间,特意多花了一点时间对scala中的集合类做个详细的总结。 1.数组Array 在说集合类之前,先看看scala中的数组。与Java中不同的是,Scala中没有数组这一种类型。在Scala中,Array类的功能就与数组类似。 与所有数组一样,Array的长度不可变,里面的数据可以按索引位置访问。 def test() = { val array1 = new Array[Int]( 5 ) array1( 1 ) = 1 println(array1( 1 )) val array2 = Array( 0 , 1 , 2 , 3 , 4 ) println(array2( 3 )) } 上面的demo就演示了Array的简单用法。 2.集合类的大致结构 盗用网上的一张图,scala中集合类的大体框架如下图所示。 特意查了下scala的源码,贴上几张图,可以对应到上面的这幅继承关系图。 根据图以及源码可以很清晰地看出scala中的集合类可以分为三大类: 1.Seq,是一组有序的元素。 2.Set,是一组没有重复元素的集合。 3.Map,是一组k-v对。 3.Seq分析 Seq主要由两部分组成