从带有imagePicker画廊中选择的图像没有上传到firebase存储
我有这样的代码:
Future pickImage() async {
try {
var image = await ImagePicker().pickImage(source: ImageSource.gallery);
if(image == null) return;
final imageTemp = File(image.path);
setState(() {
_image = imageTemp;
print("file: " + image.toString()); // I/flutter (20502): file: Instance of 'XFile'
print("file: " + image.path); // I/flutter (20502): file: /data/user/0/io.bolataktar.com/cache/image_picker1927171545041404148.jpg
});
final mountainsRef = storageRef.child(image.path);
} catch (e) {
print(e);
}
}
在此代码中,我输入图库,可以从那里选择一个图像。但是选择图像后,我希望它上传到Firebase存储。但是该图像没有上传到Firebase存储。为什么会?我没有遇到任何错误。
执行 @user18309290之后:
代码:
try {
var image = await ImagePicker().pickImage(source: ImageSource.gallery);
if(image == null) return;
final imageTemp = File(image.path);
setState(() {
_image = imageTemp;
print("file: " + image.toString()); // I/flutter (20502): file: Instance of 'XFile'
print("file: " + image.path); // I/flutter (20502): file: /data/user/0/io.bolataktar.com/cache/image_picker1927171545041404148.jpg
});
final mountainsRef = storageRef.child(image.path);
await mountainsRef.putFile(imageTemp); // added
} catch (e) {
print(e);
}
错误:
W/.bolataktar.co(20502): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
E/flutter (20502): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method Task#startPutFile on channel plugins.flutter.io/firebase_storage)
E/flutter (20502): #0 MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:175
E/flutter (20502): <asynchronous suspension>
E/flutter (20502):
I/flutter (20502): MissingPluginException(No implementation found for method Task#startPutFile on channel plugins.flutter.io/firebase_storage)
I have a code like this:
Future pickImage() async {
try {
var image = await ImagePicker().pickImage(source: ImageSource.gallery);
if(image == null) return;
final imageTemp = File(image.path);
setState(() {
_image = imageTemp;
print("file: " + image.toString()); // I/flutter (20502): file: Instance of 'XFile'
print("file: " + image.path); // I/flutter (20502): file: /data/user/0/io.bolataktar.com/cache/image_picker1927171545041404148.jpg
});
final mountainsRef = storageRef.child(image.path);
} catch (e) {
print(e);
}
}
In this code I enter the gallery and I can select an image from there. But after selecting image I want it to upload to Firebase Storage. But the image is not uploading to Firebase Storage. Why could it be? I am not getting any errors.
After doing what @user18309290 said:
Code:
try {
var image = await ImagePicker().pickImage(source: ImageSource.gallery);
if(image == null) return;
final imageTemp = File(image.path);
setState(() {
_image = imageTemp;
print("file: " + image.toString()); // I/flutter (20502): file: Instance of 'XFile'
print("file: " + image.path); // I/flutter (20502): file: /data/user/0/io.bolataktar.com/cache/image_picker1927171545041404148.jpg
});
final mountainsRef = storageRef.child(image.path);
await mountainsRef.putFile(imageTemp); // added
} catch (e) {
print(e);
}
Error:
W/.bolataktar.co(20502): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
E/flutter (20502): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method Task#startPutFile on channel plugins.flutter.io/firebase_storage)
E/flutter (20502): #0 MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:175
E/flutter (20502): <asynchronous suspension>
E/flutter (20502):
I/flutter (20502): MissingPluginException(No implementation found for method Task#startPutFile on channel plugins.flutter.io/firebase_storage)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
上传零件丢失。
The uploading part is missing.