MCPcopy Create free account
hub / github.com/CodeFox-Repo/codefox / streamToBuffer

Method streamToBuffer

backend/src/upload/upload.service.ts:166–174  ·  view source on GitHub ↗

* Convert a readable stream to a buffer * @param stream Readable stream * @returns Promise with buffer

(stream: NodeJS.ReadableStream)

Source from the content-addressed store, hash-verified

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

Callers 1

uploadMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected