veza/apps/web/src/services/uploadService.ts

25 lines
754 B
TypeScript
Raw Normal View History

export const uploadService = {
uploadFile: async (file: File, onProgress?: (progress: number) => void) => {
// Simulate upload process
const totalSteps = 20;
const stepTime = 100 + Math.random() * 200; // Random speed
for (let i = 1; i <= totalSteps; i++) {
await new Promise(resolve => setTimeout(resolve, stepTime));
const progress = (i / totalSteps) * 100;
if (onProgress) onProgress(progress);
}
return {
upload_id: `up-${Date.now()}-${Math.random().toString(36).substr(2, 5)}`,
status: 'completed',
url: URL.createObjectURL(file) // For mock preview
};
},
getUploadStatus: async (_id: string) => {
return { status: 'completed', progress: 100 };
},
};