我正在使用flutter在Android应用上工作。在我的应用程序中,有一个功能,用户可以从他们的设备上传图像。用于存储图像我使用firebase云存储& amp;这是我用于将文件上传到firebase云存储的代码的一部分。
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}');
以下是我使用的3个相关的颤动插件,它帮助上面的代码上传文件。
import 'package:uuid/uuid.dart';
import 'package:path/path.dart' as p;
import 'package:firebase_storage/firebase_storage.dart';
一切正常。除了文件上传需要花费很多时间。几乎需要40-50秒才能完成STEP-3(print('STEP 3: downloadUrl data received - 333 : $downloadUrl');
)。有时1&半分钟也。关于我的互联网速度,它上传了几乎80Mbps的速度。下载。我的平均值上传的图片大小为100kB。
需要一些帮助。问题是什么。
从我的Android Studio日志添加屏幕截图(文件大小为2.8 MB ) -
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
注意:这可能是一个插件问题。所以,在Github上提出了一个问题