本文介绍了上传提取的进度指标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力寻找使用实施上传进度指标的文档或示例。



,其中规定:

如何编写传递流以监控字节 ?如果它有什么不同,我试图通过浏览器将图片上传到。



注意:我 对,因为它依赖于jQuery而我的应用程序没有。我只对使用原生javascript和Github的 fetch polyfill来完成此操作所需的流处理感兴趣。






流正开始登陆网络平台(),但它仍然是早期的日子。



很快你就可以提供一个流作为请求的主体,但是开放的问题是该流的消耗是否与上传的字节有关。





有些人质疑是否将流消费链接到上传的字节是否有意义。



Long故事简介:这还不可能,但将来这将由流处理,或者传递到 fetch()的某种更高级别的回调。


I'm struggling to find documentation or examples of implementing an upload progress indicator using fetch.

This is the only reference I've found so far, which states:

How would I write "a pass-through stream to monitor the bytes" sent? If it makes any sort of difference, I'm trying to do this to power image uploads from the browser to Cloudinary.

NOTE: I am not interested in the Cloudinary JS library, as it depends on jQuery and my app does not. I'm only interested in the stream processing necessary to do this with native javascript and Github's fetch polyfill.


https://fetch.spec.whatwg.org/#fetch-api

解决方案

Streams are starting to land in the web platform (https://jakearchibald.com/2016/streams-ftw/) but it's still early days.

Soon you'll be able to provide a stream as the body of a request, but the open question is whether the consumption of that stream relates to bytes uploaded.

Particular redirects can result in data being retransmitted to the new location, but streams cannot "restart". We can fix this by turning the body into a callback which can be called multiple times, but we need to be sure that exposing the number of redirects isn't a security leak, since it'd be the first time on the platform JS could detect that.

Some are questioning whether it even makes sense to link stream consumption to bytes uploaded.

Long story short: this isn't possible yet, but in future this will be handled either by streams, or some kind of higher-level callback passed into fetch().

这篇关于上传提取的进度指标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-25 20:36