uploadWithBytes method

Future<StorageValue?> uploadWithBytes(
  1. Uint8List uploadFileByte
)

Uploads a file with the actual data in uploadFileByte to the location on the remote side specified by storageQuery.

You can wait in uploading while downloading.

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.relativeRemotePath.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;
  }
}