• <legend id='T5KR1'><style id='T5KR1'><dir id='T5KR1'><q id='T5KR1'></q></dir></style></legend>

    <small id='T5KR1'></small><noframes id='T5KR1'>

      <i id='T5KR1'><tr id='T5KR1'><dt id='T5KR1'><q id='T5KR1'><span id='T5KR1'><b id='T5KR1'><form id='T5KR1'><ins id='T5KR1'></ins><ul id='T5KR1'></ul><sub id='T5KR1'></sub></form><legend id='T5KR1'></legend><bdo id='T5KR1'><pre id='T5KR1'><center id='T5KR1'></center></pre></bdo></b><th id='T5KR1'></th></span></q></dt></tr></i><div id='T5KR1'><tfoot id='T5KR1'></tfoot><dl id='T5KR1'><fieldset id='T5KR1'></fieldset></dl></div>
    1. <tfoot id='T5KR1'></tfoot>
      • <bdo id='T5KR1'></bdo><ul id='T5KR1'></ul>

      1. 通过 HTTP 将数据从浏览器流式传输到服务器的方

        时间:2023-10-15
      2. <legend id='lwFYC'><style id='lwFYC'><dir id='lwFYC'><q id='lwFYC'></q></dir></style></legend>

          <tbody id='lwFYC'></tbody>

          <tfoot id='lwFYC'></tfoot>

                <bdo id='lwFYC'></bdo><ul id='lwFYC'></ul>

                  <i id='lwFYC'><tr id='lwFYC'><dt id='lwFYC'><q id='lwFYC'><span id='lwFYC'><b id='lwFYC'><form id='lwFYC'><ins id='lwFYC'></ins><ul id='lwFYC'></ul><sub id='lwFYC'></sub></form><legend id='lwFYC'></legend><bdo id='lwFYC'><pre id='lwFYC'><center id='lwFYC'></center></pre></bdo></b><th id='lwFYC'></th></span></q></dt></tr></i><div id='lwFYC'><tfoot id='lwFYC'></tfoot><dl id='lwFYC'><fieldset id='lwFYC'></fieldset></dl></div>

                  <small id='lwFYC'></small><noframes id='lwFYC'>

                  本文介绍了通过 HTTP 将数据从浏览器流式传输到服务器的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  是否有任何类似 XHR 的浏览器 API 可用于通过 HTTP 将二进制流式传输到服务器?

                  Are there any XHR-like browser APIs available for streaming binary to a server over HTTP?

                  我想随着时间的推移发出 HTTP PUT 请求并以编程方式创建数据.我不想一次创建所有这些数据,因为内存中可能存在大量数据.一些伪代码来说明我的意思:

                  I want to make an HTTP PUT request and create data programmatically, over time. I don't want to create all this data at once, since there could be gigs of it sitting in memory. Some psueudo-code to illustrate what I'm getting at:

                  var dataGenerator = new DataGenerator(); // Generates 8KB UInt8Array every second
                  var streamToWriteTo;
                  http.put('/example', function (requestStream) {
                    streamToWriteTo = requestStream;
                  });
                  
                  dataGenerator.on('data', function (chunk) {
                    if (!streamToWriteTo) {
                      return;
                    }
                    streamToWriteTo.write(chunk);
                  });
                  

                  我目前有一个 Web 套接字解决方案,但更喜欢常规 HTTP,以便与一些现有的服务器端代码更好地互操作.

                  I currently have a web socket solution in place instead, but would prefer regular HTTP for better interop with some existing server-side code.

                  我可以使用最前沿的浏览器 API.我正在查看 Fetch API,因为它支持请求正文的 ArrayBuffers、DataViews、Files 等.如果我能以某种方式伪造这些对象之一,以便我可以将 Fetch API 与动态数据一起使用,那将适用于我.我尝试创建一个代理对象,看看是否调用了我可以修补的方法.不幸的是,浏览器(至少在 Chrome 中)似乎正在阅读本机代码,而不是在 JS 领域.但是,如果我错了,请纠正我.

                  I can use bleeding edge browser APIs. I was looking at the Fetch API, as it supports ArrayBuffers, DataViews, Files, and such for request bodies. If I could somehow fake out one of these objects so that I could use the Fetch API with dynamic data, that would work for me. I tried creating a Proxy object to see if any methods were called that I could monkey patch. Unfortunately, it seems that the browser (at least in Chrome) is doing the reading in native code and not in JS land. But, please correct me if I'm wrong on that.

                  推荐答案



                  我目前正在寻找完全相同的东西(通过 Ajax 上传).我目前的发现,看起来好像我们正在搜索浏览器功能设计的最前沿;-)

                  XMLHttpRequest 定义 在步骤 4 bodyinit 这个内容提取是(或可以是)一个可读流.

                  我仍在(作为非网络开发人员)搜索有关如何创建这样的东西并将数据提供给可读流"的另一端"的信息(即应该是可写流",但我还没有没找到).

                  如果您找到了实施这些设计计划的方法,也许您在搜索方面做得更好,并且可以在此处发布.

                  ^5
                  斯文



                  I'm currently searching for exactly the same thing (upstreaming via Ajax). What I currently found, looks as if we are searching at the bleeding edge of browser's feature design ;-)

                  XMLHttpRequest definition tells in step 4 bodyinit that the content extraction of this is (or can be) a readablestream.

                  I'm still searching (as a non-webdeveloper) for information of how to create such a thing and to feed data into the "other end" of that "readablestream" (which namely should be a "writablestream", but I yet did not find that).

                  Maybe you are better in searching and can post here if you found a method to implement these design plans.

                  ^5
                  sven

                  这篇关于通过 HTTP 将数据从浏览器流式传输到服务器的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何发送“&amp;"?通过 AJAX 的(和号)字符? 下一篇:如何在 IE 中从 Javascript 访问 XHR responseBody(用于二

                  相关文章

                  最新文章

                    <small id='4mIwi'></small><noframes id='4mIwi'>

                    <legend id='4mIwi'><style id='4mIwi'><dir id='4mIwi'><q id='4mIwi'></q></dir></style></legend>
                      <bdo id='4mIwi'></bdo><ul id='4mIwi'></ul>
                    1. <tfoot id='4mIwi'></tfoot>
                    2. <i id='4mIwi'><tr id='4mIwi'><dt id='4mIwi'><q id='4mIwi'><span id='4mIwi'><b id='4mIwi'><form id='4mIwi'><ins id='4mIwi'></ins><ul id='4mIwi'></ul><sub id='4mIwi'></sub></form><legend id='4mIwi'></legend><bdo id='4mIwi'><pre id='4mIwi'><center id='4mIwi'></center></pre></bdo></b><th id='4mIwi'></th></span></q></dt></tr></i><div id='4mIwi'><tfoot id='4mIwi'></tfoot><dl id='4mIwi'><fieldset id='4mIwi'></fieldset></dl></div>