download method
Future<void>
download(
- String url,
- String targetPath, {
- String? token,
- CancelToken? cancelToken,
override
Downloads a file from URL to target path
Parameters:
url
: Source URL (must be HTTP/HTTPS)targetPath
: Full path where file should be savedtoken
: Optional authentication tokencancelToken
: Optional token for cancellation
Throws:
- DownloadException with DownloadError.network for network errors
- DownloadException with
DownloadError.fileSystem
for file write errors - DownloadCancelledException if cancelled via cancelToken
Implementation
@override
Future<void> download(
String url,
String targetPath, {
String? token,
CancelToken? cancelToken,
}) async {
// Check cancellation before starting
cancelToken?.throwIfCancelled();
// On web, just register the URL - no actual download
// MediaPipe will fetch it when creating a session
_fileSystem.registerUrl(targetPath, url);
debugPrint('WebDownloadService: Registered URL for $targetPath');
// Note: Token is stored but not used here
// It would need to be passed to MediaPipe when creating session
if (token != null) {
debugPrint('WebDownloadService: Token provided (will be used by MediaPipe)');
}
}