Reputation: 1355
This is my first question in StackOverflow.
I am trying to upload video to Firebase Storage, but it takes too long to upload a file. I tested with a 30MB file that took 3-4 minutes to finish O_O and another 100MB video took 6-7 minutes.
I have an internet connection of 50Mb/sec (upload-download) so I expected it to be faster.
Note: I am using the latest versions of firebase
and file_picker
.
Is this a problem with Flutter or is there something I need to do?
Future selectFile() async {
final result = await FilePicker.platform.pickFiles(allowMultiple: false);
if (result == null) return;
final path = result.files.single.path;
setState(() => file = File(path));
}
Future uploadFile() async {
if (file == null) return;
final fileName = basename(file.path);
final destination = 'files/$fileName';
task = FirebaseApi.uploadFile(destination, file);
setState(() {});
if (task == null) return;
final snapshot = await task.whenComplete(() {});
final urlDownload = await snapshot.ref.getDownloadURL();
await FirebaseFirestore.instance.collection("users").doc(currentUser.uid).update({
'image1': urlDownload,
});
}
class FirebaseApi {
static UploadTask uploadFile(String destination, File file) {
try {
final ref = FirebaseStorage.instance.ref(destination);
return ref.putFile(file);
} on FirebaseException catch (e) {
return null;
}
}
Thanks in advance ^_^
Upvotes: 0
Views: 665
Reputation: 573
I think that's how it is. In my app, uploading a compressed imgae takes around 5- 6 seconds.
Have you ever tried to upload a video to an instant messaging app like WhatsApp? There, the upload isn't that fast either.
(Note: Are you sure you have 50 mBit/s in upload speed? That seems a lot to me)
Upvotes: 1