download method
Download the file on the remote side specified by storageQuery to localRelativePath
on the local side.
You can wait in downloading while downloading.
The full path of the cache to download can be obtained as a return value.
storageQueryで指定されたリモート側のファイルをローカル上のlocalRelativePath
にダウンロードします。
ダウンロード中はdownloadingで待つことができます。
戻り値としてダウンロード先のキャッシュのフルパスを取得することが出来ます。
Implementation
Future<StorageValue?> download([String? localRelativePath]) async {
if (_downloadCompleter != null) {
await downloading;
return value;
}
_downloadCompleter = Completer();
try {
final localFile = await storageQuery.adapter.download(
storageQuery.relativeRemotePathOrId.trimQuery().trimStringRight("/"),
localRelativePath?.trimQuery().trimStringRight("/"),
);
_value = _value?._copyWith(
local: localFile,
) ??
StorageValue._(
local: localFile,
);
notifyListeners();
_downloadCompleter?.complete();
_downloadCompleter = null;
return _value;
} catch (e) {
_downloadCompleter?.completeError(e);
_downloadCompleter = null;
rethrow;
} finally {
_downloadCompleter?.complete();
_downloadCompleter = null;
}
}