Skip to main content
Glama
sftp.ts908 B
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import type { Readable } from 'node:stream'; /** * Reads data from a Readable stream and returns a Promise that resolves with a Buffer containing all the data. * @param stream - The Readable stream to read from. * @returns A Promise that resolves with a Buffer containing all the data from the Readable stream. */ export function streamToBuffer(stream: Readable): Promise<Buffer> { const chunks: Uint8Array[] = []; return new Promise<Buffer>((resolve, reject) => { stream.on('data', (chunk: Uint8Array) => chunks.push(Buffer.from(chunk))); stream.on('error', (err: Error) => { stream.destroy(); reject(err); }); stream.on('end', () => { resolve(Buffer.concat(chunks)); }); stream.on('close', () => { stream.destroy(); }); }); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/medplum/medplum'

If you have feedback or need assistance with the MCP directory API, please join our Discord server