uploadWithBytes method

  1. @override
Future<RemoteFile> uploadWithBytes(
  1. Uint8List uploadFileByte,
  2. String remoteRelativePath
)
override

Uploads the data specified in uploadFileByte to remoteRelativePath, which is the location on the remote side.

The byte data of the file is passed to uploadFileByte and the relative path is passed to remoteRelativePath.

Return RemoteFile containing the full path of the upload destination and the actual data as the return value.

uploadFileByteで指定されたデータをリモート側の位置であるのremoteRelativePathにアップロードします。

uploadFileByteにファイルのバイトデータが渡されremoteRelativePathに相対パスが渡されます。

戻り値としてアップロード先のフルパスと実データを格納したRemoteFileを返してください。

Implementation

@override
Future<RemoteFile> uploadWithBytes(
  Uint8List uploadFileByte,
  String remoteRelativePath,
) async {
  await FirebaseCore.initialize(options: options);
  try {
    assert(uploadFileByte.isNotEmpty, "Bytes is empty.");
    final uploadTask = reference(remoteRelativePath).putData(uploadFileByte);
    await Future.value(uploadTask);
    return RemoteFile(path: await fetchPublicURI(remoteRelativePath));
  } catch (e) {
    rethrow;
  }
}