upload method

Future<StorageValue?> upload(
  1. String localFullPath
)

Uploads a file located at localFullPath on the local to the remote location specified by storageQuery.

You can wait in uploading while downloading.

The full path to the upload destination can be obtained as a return value.

ローカル上のlocalFullPathにあるファイルをstorageQueryで指定されたリモート側の位置にアップロードします。

ダウンロード中はuploadingで待つことができます。

戻り値としてアップロード先のフルパスを取得することが出来ます。

Implementation

Future<StorageValue?> upload(String localFullPath) async {
  if (_uploadCompleter != null) {
    await uploading;
    return value;
  }
  _uploadCompleter = Completer();
  try {
    final remoteFile = await storageQuery.adapter.upload(
      localFullPath.trimQuery().trimStringRight("/"),
      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;
  }
}