UNPKG

smart-dropzone-react

Version:

🚀 A production-ready React dropzone component with smart defaults, drag & drop reordering, chunked uploads, resume functionality, and comprehensive provider support (Cloudinary, AWS S3, Supabase)

69 lines (67 loc) • 2.06 kB
interface UploadChunk { id: string; start: number; end: number; data: Blob; uploaded: boolean; retryCount: number; maxRetries: number; } interface ResumeOptions { chunkSize?: number; maxConcurrentChunks?: number; retryAttempts?: number; retryDelay?: number; enableResume?: boolean; validateChunks?: boolean; checksumAlgorithm?: "md5" | "sha1" | "sha256" | "crc32"; } interface ResumeState { fileId: string; fileName: string; totalSize: number; uploadedSize: number; chunks: UploadChunk[]; status: "paused" | "resuming" | "uploading" | "completed" | "failed"; lastChunkIndex: number; checksum?: string; metadata?: Record<string, any>; } interface ResumeResult { success: boolean; uploadedSize: number; totalSize: number; chunks: UploadChunk[]; error?: string; } declare class UploadResumeManager { private static instance; private static fileIdCounter; private resumeStates; private options; private activeUploads; private chunkQueue; constructor(options?: ResumeOptions); static getInstance(): UploadResumeManager; createResumeState(file: File, provider: string): Promise<ResumeState>; resumeUpload(fileId: string, provider: any): Promise<ResumeResult>; pauseUpload(fileId: string): boolean; cancelUpload(fileId: string): boolean; getResumeState(fileId: string): ResumeState | undefined; getAllResumeStates(): ResumeState[]; clearResumeState(fileId: string): boolean; private createChunks; private calculateChecksum; private validateExistingChunks; private uploadRemainingChunks; private uploadChunk; private uploadChunkToProvider; private emitProgressEvent; private generateFileId; private delay; getUploadProgress(fileId: string): number; isUploadActive(fileId: string): boolean; getActiveUploads(): string[]; destroy(): void; } export { type ResumeOptions, type ResumeResult, type ResumeState, type UploadChunk, UploadResumeManager };