简体   繁体   English

如何限制Node.js / Express 4中的上传?

[英]How can I throttle uploads in Node.js / Express 4?

I would like to throttle file uploads in Express 4. By that I mean the bytes per second, not the number of API calls. 我想在Express 4中限制文件上传。我的意思是每秒的字节数,而不是API调用的数量。

I want to be able to simulate a slow connection for file uploads so I can test out my progress animations. 我希望能够模拟文件上传的慢速连接,以便我可以测试我的进度动画。

I only want to limit the file upload endpoint and not the other endpoints. 我只想限制文件上传端点而不是其他端点。 How can I do this? 我怎样才能做到这一点?

Ideally, I'd like to add some middleware on the specific endpoint and specify the transfer speed in bytes/s. 理想情况下,我想在特定端点上添加一些中间件,并以字节/秒为单位指定传输速度。

If you are on OSX and just interested in some occasional testing (as opposed to a standardized test response) I'd take a look at the Apple Network Link Conditioner. 如果您使用OSX并且只对偶尔的测试感兴趣(而不是标准化的测试响应),我会看一下Apple Network Link Conditioner。 Here's some info . 这是一些信息

Also it appears that recent versions of Chromium and I assume Chrome have built in network throttling options in the dev tools. 此外,最近版本的Chromium和我认为Chrome在开发工具中内置了网络限制选项。

看起来Chrome开发者工具也允许您配置较慢的网络。

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

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