Spaces:
Running
Running
File size: 861 Bytes
5539271 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | import type { Document } from '../../shared/types'
import { apiFetch } from '../../shared/api/http'
export function fetchDocuments(): Promise<Document[]> {
return apiFetch<Document[]>('/api/documents')
}
export function fetchDocument(id: string): Promise<Document> {
return apiFetch<Document>(`/api/documents/${id}`)
}
export async function uploadDocument(file: File): Promise<Document> {
const formData = new FormData()
formData.append('file', file)
return apiFetch<Document>('/api/documents/upload', {
method: 'POST',
body: formData,
skipContentType: true,
})
}
export function deleteDocument(id: string): Promise<unknown> {
return apiFetch(`/api/documents/${id}`, { method: 'DELETE' })
}
export function getPreviewUrl(id: string, page = 1, dpi = 150): string {
return `/api/documents/${id}/preview?page=${page}&dpi=${dpi}`
}
|