Skip to main content
Glama
form-data-upload.ts1.11 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import type { MedplumClient } from '@medplum/core'; import FormData from 'form-data'; import fetch from 'node-fetch'; export async function handler(medplum: MedplumClient): Promise<any> { // Create the PDF const binary = await medplum.createPdf({ docDefinition: { content: ['Hello Medplum'], }, }); console.log('Binary result', JSON.stringify(binary, null, 2)); if (!binary.url) { throw new Error('Binary is missing'); } // Download the PDF const pdfData = await medplum.download(binary.url); const pdfStream = await pdfData.stream(); // Create a multipart form body const form = new FormData(); form.append('otherValue', 'hello medplum'); form.append('testPdf', pdfStream); // Post the form const response = await fetch('https://httpbin.org/post', { method: 'POST', body: form, headers: form.getHeaders(), }); // Show the JSON response const json = await response.json(); console.log('response', json); return json; }

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