【问题标题】:I was trying to upload video on firebase but it gives me an error我试图在 firebase 上上传视频,但它给了我一个错误
【发布时间】:2020-06-04 13:13:54
【问题描述】:
The method 'existsSync' was called on null.
Receiver: null
Tried calling: existsSync()
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1      StorageReference.putFile (package:firebase_storage/src/storage_reference.dart:62:17)
#2      _UploadState.uploadImage (package:focal/pages/upload.dart:402:10)
#3      _UploadState.handleVideoSubmit (package:focal/pages/upload.dart:507:30)
<asynchronous suspension>

#4      _UploadState.buildUploadForm.<anonymous closure>       (package:focal/pages/upload.dart:613:27)
#5      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:779:19)
#6      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:862:36)
#7      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
#8      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:504:11)
#9      BaseTapGestureRecognizer._chec<…>

这个错误是什么意思 我刚刚上传了一个视频文件,它给了我这个错误。

这是我上传视频的代码

final StorageReference storageRef = FirebaseStorage.instance.ref();

 Future<String> uploadVideo(videoFile, String postId) async {
StorageUploadTask uploadTask = storageRef
    .child(
      'post_/$postId/${widget.currentuser.username}',
    )
    .putFile(videoFile);
String thumbnail = 'post_/$postId/${widget.currentuser.username}';
setState(() {
  thumbnailLocation = thumbnail;
});
StorageTaskSnapshot storageSnap = await uploadTask.onComplete;
String downloadUrl = await storageSnap.ref.getDownloadURL();
return downloadUrl;

}

【问题讨论】:

  • 请分享您的确切小部件代码和方法。还要编辑您的问题以提高可读性。
  • 见上文,你很可能在执行 existsSync(value) ,其中 value 为空。 Console.log 将您传递给函数的值
  • 该错误表示没有文件,您需要分享您的代码以获得任何帮助
  • @PeterHaddad 我已经编辑了我的代码,看看它

标签: firebase flutter google-cloud-firestore firebase-storage


【解决方案1】:

检查你是否已经初始化storageRef

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-14
    • 2022-07-21
    • 2012-05-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多