Skip to documentation
Beacon Docs
TypeScript SDK

Upload media

Upload validated media through the stable TypeScript SDK media API.

Open Markdown

Use client.media.upload with media:write permission.

const bytes = await Bun.file("release-card.png").arrayBuffer();
const file = new Blob([bytes], { type: "image/png" });

const uploaded = await client.media.upload(
  {
    altText: "A release card with the Beacon logo.",
    confirmed: true,
    file,
    fileName: "release-card.png",
  },
  { idempotencyKey: crypto.randomUUID() },
);

Beacon checks the actual file bytes. It does not trust the browser MIME type alone.

Use client.media.list, client.media.get, and client.media.getImage for reads. The old client.experimental.media name remains as a deprecated compatibility alias.

Do not retry an upload automatically after an unknown result. Read the media list before you decide what to do next.