some change

This commit is contained in:
john 2025-05-16 16:09:35 +02:00
parent d4a1492d56
commit 313f1def49
38 changed files with 475 additions and 401 deletions

View file

@ -0,0 +1,22 @@
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) }
}
}