Qassure-frontend/src/services/file-service.ts

28 lines
840 B
TypeScript

import apiClient from './api-client';
export interface FileUploadResponse {
success: boolean;
data: {
original_name: string;
file_path: string;
file_url: string;
mime_type: string;
file_size: number;
file_size_formatted: string;
uploaded_at: string;
};
}
export const fileService = {
uploadSimple: async (file: File): Promise<FileUploadResponse> => {
const formData = new FormData();
formData.append('file', file);
// Axios automatically sets Content-Type to multipart/form-data with boundary for FormData
// The interceptor will still add the Authorization header
// Don't set Content-Type explicitly - let axios handle it with the correct boundary
const response = await apiClient.post<FileUploadResponse>('/files/upload/simple', formData);
return response.data;
},
};