我一直在开发一个带有抖动的应用程序,其中用户拍摄了一系列照片,并且该应用程序生成了照片(或视频)的时间间隔。我使用平台渠道生成mp4视频,但是,将mp4上传到Firebase存储时,视频上传为空。我可以验证mp4的编写是否正确,因为我可以在笔记本电脑上观看模拟器编写的视频。
以前有人遇到过此错误吗?
以下是用于上传到Firebase存储的代码:
Future saveMp4(File mp4File, User user, String date) async {
StorageReference ref = firestorage
.ref()
.child(user.uid)
.child("videos")
.child(date+'.mp4');
print (mp4File);
StorageUploadTask uploadTask = ref.putFile(mp4File, StorageMetadata(contentType: 'video/mp4'));
await uploadTask.onComplete;
String downloadUrl = await ref.getDownloadURL();
print ("download url: $downloadUrl");
}
以下是上传事件的输出以及包含视频的文件的位置。
flutter: File: '/Users/ryanmorris/Library/Developer/CoreSimulator/Devices/9A6FB4BC-90B2-4AF4-A622-841979AD5430/data/Containers/Data/Application/554FDF1E-0793-47DA-964A-AF661D46CEA1/Documents/export.mp4'
flutter: EVENT StorageTaskEventType.progress
flutter: EVENT StorageTaskEventType.resume
flutter: EVENT StorageTaskEventType.progress
[C33.1 8D504A8D-BFFF-468C-8970-17985062A8CB 192.168.1.22:62408<->172.217.23.10:443]
Connected Path: satisfied (Path is satisfied), interface: en0
Duration: 1.029s, DNS @0.001s took 0.005s, TCP @0.008s took 0.026s, TLS took 0.052s
bytes in/out: 3976/1035, packets in/out: 10/8, rtt: 0.043s, retransmitted packets: 0, out-of-order packets: 0
flutter: EVENT StorageTaskEventType.progress
flutter: EVENT StorageTaskEventType.success
在IOS平台上,我使用了https://github.com/cameronehrlich/CEMovieMaker中的代码。我不认为问题出在平台代码上,因为我可以很好地播放输出视频。
这是我扑扑的医生的输出:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.9.4, on Mac OS X 10.14.1 18B50c, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.2)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.0)
[✓] Android Studio (version 3.1)
[✓] Connected devices (1 available)
firebase_storage版本为1.0.3。
谢谢您的帮助!
答案 0 :(得分:0)
请确保在temp文件夹中创建文件时,writeAsBytes操作是异步操作,您必须等待或执行上载才能在.then((File f){..})
中进行存储