<bdo id='d0Tgg'></bdo><ul id='d0Tgg'></ul>
    1. <small id='d0Tgg'></small><noframes id='d0Tgg'>

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

      1. <tfoot id='d0Tgg'></tfoot>

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

        时间:2023-05-16

          <tfoot id='7lBB8'></tfoot>
        1. <legend id='7lBB8'><style id='7lBB8'><dir id='7lBB8'><q id='7lBB8'></q></dir></style></legend>

            • <bdo id='7lBB8'></bdo><ul id='7lBB8'></ul>

              <small id='7lBB8'></small><noframes id='7lBB8'>

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

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

                  问题描述

                  限时送ChatGPT账号..

                  是否有任何类似 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 将数据从浏览器流式传输到服务器的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文章

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

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

                      <tfoot id='hKuax'></tfoot>
                      • <bdo id='hKuax'></bdo><ul id='hKuax'></ul>