fetchToStorage method
Silent download into UFileStorage. Returns the key once the file is stored.
Implementation
Future<String> fetchToStorage(
String url,
String key, {
UStorageBucket bucket = UStorageBucket.support,
Map<String, String> headers = const <String, String>{},
void Function(double progress)? onProgress,
UChecksum? checksum,
Duration? expireIn,
bool persistent = true,
}) async {
final UDownloadTask task = await enqueue(
UDownloadRequest(
url: url,
headers: headers,
destination: UDownloadDestination.storage(key, bucket: bucket),
visible: false,
persistent: persistent,
priority: UDownloadPriority.high,
checksum: checksum,
expireIn: expireIn,
conflict: UDownloadConflict.overwrite,
),
);
return _await(task, onProgress, (UDownloadTask t) => key);
}