flutter: upload a video to firebase storage and get the link

Viewed 891

I tried to upload the video using image picker to firebase storage and get the link but there's a problem!

At first, this is my upload video method:

Future<void> uploadVideo() async {
await ImagePicker.pickVideo(source: ImageSource.gallery).then((value) {
  setState(() {
    _video = value;
  });
});
StorageReference storageReference = FirebaseStorage.instance
    .ref()
    .child('revisionVideos/${Path.basename(_video.path)}');
StorageUploadTask storageUploadTask = storageReference.putFile(
    _video, StorageMetadata(contentType: 'video/mp4'));
await storageUploadTask.onComplete;
print('Video Uploaded');
storageReference.getDownloadURL().then((value) {
  setState(() {
    _videoUrl = value;
  });
});
}

When I upload the video, there was a photo (there's an error when trying to preview it) not a video.

enter image description here

And in the run tab:

W/StorageUtil(17625): no auth token for request
W/NetworkRequest(17625): no auth token for request
W/StorageUtil(17625): no auth token for request
W/NetworkRequest(17625): no auth token for request
D/UploadTask(17625): Increasing chunk size to 1048576

Although I edited the rules in the storage and cloud firestore, too.

Add: I didn't add authentication page for this application and the firebase project is linked to 2 android apps.

0 Answers
Related