Regression: Apps-Engine - Convert streams to buffers on file upload (#20523)
Co-authored-by: Diego Sampaio <chinello@gmail.com>pull/20535/head
parent
2c81c0ead1
commit
d420c21396
@ -0,0 +1,11 @@ |
||||
import { Readable } from 'stream'; |
||||
|
||||
export const streamToBuffer = (stream: Readable): Promise<Buffer> => new Promise((resolve) => { |
||||
const chunks: Array<Buffer> = []; |
||||
|
||||
stream |
||||
.on('data', (data) => chunks.push(data)) |
||||
.on('end', () => resolve(Buffer.concat(chunks))) |
||||
// force stream to resume data flow in case it was explicitly paused before
|
||||
.resume(); |
||||
}); |
||||
Loading…
Reference in new issue