Flutter Firebase存储上传流

问题描述 投票:0回答:1

我正在将多个图像上传到Cloud Storage,我已经读到可以点按流以显示上传进度条,但是我看不到这样做的方法。

  Future<dynamic> postImage(Asset imageFile) async {
    String fileName = DateTime.now().toString();
    StorageReference reference = FirebaseStorage.instance.ref().child(fileName);
    StorageUploadTask _uploadTask =
        reference.putData((await imageFile.getByteData()).buffer.asUint8List());
    StorageTaskSnapshot storageTaskSnapshot = await _uploadTask.onComplete;
    return storageTaskSnapshot.ref.getDownloadURL();
  }
firebase flutter firebase-storage
1个回答
0
投票

在FlutterFire仓库中有一个example of how to use the firebase-storage plugin,非常方便。

© www.soinside.com 2019 - 2024. All rights reserved.