简体   繁体   中英

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.

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. 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.

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

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