import { api } from '../index'; import type { UploadResponse } from '../types'; /** * Build the multipart body for `/upload`. The backend expects exactly one file * per request under the field name `file` (anything else → FastAPI 422). */ export function buildUploadFormData(file: File): FormData { const fd = new FormData(); fd.append('file', file); return fd; } export const uploadApi = api.injectEndpoints({ endpoints: (build) => ({ uploadTrack: build.mutation({ query: (formData) => ({ url: '/upload', method: 'POST', body: formData, formData: true, }), invalidatesTags: ['Track', 'Album', 'Artist', 'Storage'], }), }), overrideExisting: false, }); export const { useUploadTrackMutation } = uploadApi;