I'm working on an Android app using flutter. In my app, there is a feature where a user can upload images from their device. For storing images I'm using firebase cloud storage & here is the part of the code I'm using for uploading files to firebase cloud storage.
String fileName = "${this.userDetails['id']}_${uuid.v1()}";
String fileExtension = p.extension(_imageFile.path);
String newFileName = p.setExtension(fileName, fileExtension);
print("STEP 1: New filename of image - 111: $newFileName");
final StorageReference ref = FirebaseStorage.instance.ref().child("images/users/original/$newFileName");
final StorageUploadTask uploadTask = ref.put(
_imageFile, const StorageMetadata(contentLanguage: "en")
);
print("STEP 2: Image file uploaded - 222");
final Uri downloadUrl = (await uploadTask.future).downloadUrl;
print('STEP 3: downloadUrl data received - 333 : $downloadUrl');
final http.Response downloadData = await http.get(downloadUrl);
print('STEP 4: Download data received - 444 : ${downloadData.body}');
Here are 3 related flutter plug-in which I'm using which help above code to upload files.
import 'package:uuid/uuid.dart';
import 'package:path/path.dart' as p;
import 'package:firebase_storage/firebase_storage.dart';
Everything working fine. Except, file uploading is taking a lot of time. Almost it's taking more than 40-50 seconds to complete STEP-3(print('STEP 3: downloadUrl data received - 333 : $downloadUrl');
). Sometimes 1 & half minutes also. About my internet speed, it's it has almost 80Mbps upload & download. My avg. uploaded image size is 100kB.
Need some help to fig. out what's the issue.
Adding a Screenshot(file size of 2.8 MB) from my Android Studio log -
I/flutter ( 4451): cliked on image upload button
I/flutter ( 4451): Loading animation started
I/flutter ( 4451): 2018-06-06 23:15:30.327722 - STEP 1: New file name got - 111: KyvU5PFfLRPxYFwHaiKHuywilMV2_679b9ee0-4800-11e8-fe1b-7f6c98d5147d.png
I/flutter ( 4451): 2018-06-06 23:15:30.329420 - STEP 2: Image file uploaded - 222
W/DynamiteModule( 4451): Local module descriptor class for com.google.android.gms.firebasestorage not found.
W/zygote64( 4451): Unsupported class loader
W/zygote64( 4451): Skipping duplicate class check due to unsupported classloader
I/DynamiteModule( 4451): Considering local module com.google.android.gms.firebasestorage:0 and remote module com.google.android.gms.firebasestorage:6
I/DynamiteModule( 4451): Selected remote version of com.google.android.gms.firebasestorage, version >= 6
W/zygote64( 4451): Unsupported class loader
W/zygote64( 4451): Skipping duplicate class check due to unsupported classloader
I/FlutterActivityDelegate( 4451): onResume setting current activity to this
D/UploadTask( 4451): Increasing chunk size to 524288
D/UploadTask( 4451): Increasing chunk size to 1048576
D/UploadTask( 4451): Increasing chunk size to 2097152
I/flutter ( 4451): 2018-06-06 23:17:43.445542 - STEP 3: downloadUrl image data - 333 :
I/flutter ( 4451): 2018-06-06 23:17:46.757227 - STEP 4: Download data - 444 : ÿØÿá1(Exif
NOTE: This is maybe a plugin issue. So, Filed an issue on Github
Link: https://github.com/flutter/flutter/issues/18325
I've tried using firebase_storage: ^7.0.0
recently, and uploading a 1MB image only took a few seconds.
Have you tried the latest version of firebase_storage
plugin and see if the same behavior persists? Given the logs provided, it doesn't seem to indicate any issues aside from the time consumed uploading the image. You can also try uploading files through a different network (i.e. mobile) and see if there's any difference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With