uploadWithBytes method
Uploads a file with the actual data in uploadFileByte
to the location on the remote side specified by storageQuery.
While uploading, you can wait at uploading.
It takes a StorageValue as a return value and can retrieve both local and remote data.
uploadFileByte
の実データを持つファイルをstorageQueryで指定されたリモート側の位置にアップロードします。
アップロード中はuploadingで待つことができます。
戻り値としてStorageValueを受け取り、ローカルとリモートの両方のデータを取得することができます。
Implementation
Future<StorageValue?> uploadWithBytes(Uint8List uploadFileByte) async {
if (_uploadCompleter != null) {
await uploading;
return value;
}
_uploadCompleter = Completer();
try {
final remoteFile = await storageQuery.adapter.uploadWithBytes(
uploadFileByte,
storageQuery.relativeRemotePathOrId.trimQuery().trimStringRight("/"),
);
_value = _value?._copyWith(
remote: remoteFile,
) ??
StorageValue._(
remote: remoteFile,
);
notifyListeners();
_uploadCompleter?.complete();
_uploadCompleter = null;
return _value;
} catch (e) {
_uploadCompleter?.completeError(e);
_uploadCompleter = null;
rethrow;
} finally {
_uploadCompleter?.complete();
_uploadCompleter = null;
}
}