| 1614 | this.emit('request', this); |
| 1615 | |
| 1616 | const getProgressMonitor = () => { |
| 1617 | const lengthComputable = true; |
| 1618 | const total = req.getHeader('Content-Length'); |
| 1619 | let loaded = 0; |
| 1620 | |
| 1621 | const progress = new Stream.Transform(); |
| 1622 | progress._transform = (chunk, encoding, callback) => { |
| 1623 | loaded += chunk.length; |
| 1624 | this.emit('progress', { |
| 1625 | direction: 'upload', |
| 1626 | lengthComputable, |
| 1627 | loaded, |
| 1628 | total |
| 1629 | }); |
| 1630 | callback(null, chunk); |
| 1631 | }; |
| 1632 | |
| 1633 | return progress; |
| 1634 | }; |
| 1635 | |
| 1636 | const bufferToChunks = (buffer) => { |
| 1637 | const chunkSize = 16 * 1024; // default highWaterMark value |