* Convert a readable stream to a buffer * @param stream Readable stream * @returns Promise with buffer
(stream: NodeJS.ReadableStream)
| 164 | * @returns Promise with buffer |
| 165 | */ |
| 166 | private async streamToBuffer(stream: NodeJS.ReadableStream): Promise<Buffer> { |
| 167 | const chunks: Buffer[] = []; |
| 168 | |
| 169 | return new Promise((resolve, reject) => { |
| 170 | stream.on('data', (chunk) => chunks.push(Buffer.from(chunk))); |
| 171 | stream.on('error', (err) => reject(err)); |
| 172 | stream.on('end', () => resolve(Buffer.concat(chunks))); |
| 173 | }); |
| 174 | } |
| 175 | |
| 176 | /** |
| 177 | * Get the bucket URL to use in the returned file URL |