resume_upload_sdk 1.0.0
resume_upload_sdk: ^1.0.0 copied to clipboard
A Flutter SDK for resumable file uploads with chunk-based upload support and automatic resume capability. Supports pause, resume, cancel, and progress tracking across all platforms.
resume_upload_sdk #
A Flutter SDK for resumable file uploads with chunk-based upload support and automatic resume capability.
Features #
- Resumable uploads - Automatically resumes interrupted uploads from where they left off
- Chunk-based - Splits large files into configurable chunks for reliable uploading
- Progress tracking - Real-time upload progress via stream-based callbacks
- Pause / Resume / Cancel - Full control over upload lifecycle
- CRC32 verification - Integrity checks for each uploaded chunk
- Cross-platform - iOS, Android, macOS, Windows, Linux, and Web
- Concurrent uploads - Manage multiple upload tasks simultaneously
Getting Started #
Installation #
Add to your pubspec.yaml:
dependencies:
resume_upload_sdk: ^1.0.0
Then run:
flutter pub get
Usage #
Initialize the upload manager
import 'package:resume_upload_sdk/resume_upload_sdk.dart';
final config = UploadConfig(
baseUrl: 'https://your-server.com/api/upload',
timeoutSeconds: 30,
maxRetries: 3,
);
await UploadManager.instance.initialize(config);
Upload a file
final result = await UploadManager.instance.upload(
filePath: '/path/to/file.pdf',
onProgress: (progress) {
print('Upload progress: ${progress.percentage}%');
},
onComplete: (result) {
print('Upload complete: ${result.success}');
},
);
Manage uploads
// Create a task for more control
final task = UploadManager.instance.createTask(filePath: '/path/to/file.pdf');
// Start
final result = await task.start();
// Pause
task.pause();
// Resume
await task.resume();
// Cancel
task.cancel();
// Listen to progress
task.progressStream.listen((progress) {
print('${progress.percentage}%');
});
Custom configuration per upload
final customConfig = UploadConfig(
baseUrl: 'https://your-server.com/api/upload',
timeoutSeconds: 60,
maxRetries: 5,
retryDelayMs: 2000,
headers: {'Authorization': 'Bearer token'},
userId: 'user-123',
);
await UploadManager.instance.upload(
filePath: '/path/to/large-file.zip',
config: customConfig,
);
Server Requirements #
This SDK expects a server that implements the chunked upload protocol with the following endpoints:
- Init upload - Register a new file upload and receive upload metadata
- Upload chunk - Upload individual file chunks with CRC32 verification
- Merge chunks - Signal the server to merge all chunks into the final file
A reference backend implementation is available in the repository.
License #
Licensed under the Apache License, Version 2.0. See LICENSE for details.