Skip to main content

Uploading Files to Medplum

Upload via URL

For large files such as videos and images, it can be inconvenient to download contents to the client before uploading to Medplum. In these situations, you can create a Media resource with a url parameter pointing to the location of the content.

import { Media } from '@medplum/fhirtypes';

// Create a Media Resource
const MEDIA_URL = 'https://images.unsplash.com/photo-1581385339821-5b358673a883';
const media: Media = {
resourceType: 'Media',
basedOn: [
{
reference: 'ServiceRequest/12345',
},
],
status: 'completed', // `status` is a required field
content: {
title: 'plums-ts.jpg',
contentType: 'image/jpeg',
url: MEDIA_URL,
},
};

await medplum.createResource(media);

See the Client Credentials tutorial guide for how to obtain an access token