import client from '../api/client.ts' export class MediaService { constructor() {} async uploadFile(file: File): Promise<{ mediaId: string; url: URL }> { const body = new FormData() body.append('file', file) const response = await client.POST('/media', { // @ts-expect-error this endpoint takes multipart/form-data which means passing a FormData as the body // maybe openapi-fetch only wants to handle JSON? who knows body, credentials: 'include', }) if (!response.data) { throw new Error('Failed to upload file') } return { mediaId: response.data.mediaId, url: new URL(response.data.url) } } }