mirror of
https://gitlab.com/timvisee/send.git
synced 2025-12-07 06:30:53 +03:00
refactored upload away from multipart forms to binary data
This commit is contained in:
20
server/limiter.js
Normal file
20
server/limiter.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const { Transform } = require('stream');
|
||||
|
||||
class Limiter extends Transform {
|
||||
constructor(limit) {
|
||||
super();
|
||||
this.limit = limit;
|
||||
this.length = 0;
|
||||
}
|
||||
|
||||
_transform(chunk, encoding, callback) {
|
||||
this.length += chunk.length;
|
||||
this.push(chunk);
|
||||
if (this.length > this.limit) {
|
||||
return callback(new Error('limit'));
|
||||
}
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Limiter;
|
||||
Reference in New Issue
Block a user