Skip to content

Upload a file

Upload a scan, a lab result or a referral letter as a new file. The SDK encrypts it before it leaves the device.

Who can do this: a member of the folder’s key domain whose role includes Save.

The samples use the allowed helper from Access decisions.

1. Pick the folder

Use a folder locator you already hold, or list one. See Find a patient.

2. Create the file

Pass the patient’s identifier as subject. The SDK tokenizes it on the device and never sends it.

const created = await client.objects.create(
folder,
{ kind: 'file', name: 'lab-result.pdf', type: 'application/pdf', bytes: fileStream },
{ subject: mrn },
);

3. Handle the outcome

The result is a decision, or a draft when the device is offline. An allowed create returns the new locator. Its first version is always 1.

if (!('outcome' in created)) return tellOffline(created.draftId);
const saved = await allowed(created);
if (saved) render(saved.locator);

Next