简体   繁体   中英

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?

$(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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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