简体   繁体   English

如何在JavaScript中按块读取输入字节数组

[英]How to read input byte array in chunks in javascript

How could we implement to read mp4 video data as chunked byte arrays which is shown below is sends all byte buffer at the same time? 我们如何实现以块字节数组形式读取mp4视频数据,如下所示,它是同时发送所有字节缓冲区?

$(document).ready(function () {

$('#btnUploadLocal').on('click', function () {

    var files = $("#file1").get(0).files;

    var reader = new FileReader();

    reader.onload = function (e) {
        var rawData = reader.result;

            var ajaxRequest = $.ajax({
            type: "POST",
            url: "http://x.x.x.x:8080/movefile",
            contentType: false,
            processData: false,
            data: rawData
        });

        ajaxRequest.error(function (e) {
            console.log(e);
        });
    }

    reader.readAsArrayBuffer(files[0]);
});

}); });

我现在可以使用slice命令来完成;

 var chunk = file.slice(offset, offset + chunkSize);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM