fetchToStorage method

Future<String> fetchToStorage(
  1. String url,
  2. String key, {
  3. UStorageBucket bucket = UStorageBucket.support,
  4. Map<String, String> headers = const <String, String>{},
  5. void onProgress(
    1. double progress
    )?,
  6. UChecksum? checksum,
  7. Duration? expireIn,
  8. bool persistent = true,
})

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);
}