upload method

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

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

While uploading, you can wait at uploading.

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