Skip to content

The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.

383 B
Raw Blame
import { sdk } from "@lib/client"

type UploadResponse = { files?: { url: string }[] }

export const uploadRichTextImage = async (file: File): Promise<string> => {
  const { files } = (await sdk.vendor.uploads.mutate({
    files: [file],
  })) as UploadResponse
  const url = files?.[0]?.url

  if (!url) {
    throw new Error("Upload did not return a file url")
  }

  return url
}