Skip to main content
Glama
base.ts1.34 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import type { Binary } from '@medplum/fhirtypes'; import type { Readable } from 'node:stream'; import type { BinarySource, BinaryStorage } from './types'; import { checkFileMetadata } from './utils'; export abstract class BaseBinaryStorage implements BinaryStorage { abstract writeFile(key: string, contentType: string | undefined, stream: BinarySource): Promise<void>; abstract readFile(key: string): Promise<Readable>; abstract copyFile(sourceKey: string, destinationKey: string): Promise<void>; abstract getPresignedUrl(binary: Binary): Promise<string>; readBinary(binary: Binary): Promise<Readable> { return this.readFile(this.getKey(binary)); } writeBinary( binary: Binary, filename: string | undefined, contentType: string | undefined, stream: BinarySource ): Promise<void> { checkFileMetadata(filename, contentType); return this.writeFile(this.getKey(binary), contentType, stream); } copyBinary(sourceBinary: Binary, destinationBinary: Binary): Promise<void> { return this.copyFile(this.getKey(sourceBinary), this.getKey(destinationBinary)); } getKey(binary: Binary): string { return 'binary/' + binary.id + '/' + binary.meta?.versionId; } }

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