简体   繁体   中英

How to upload image to web (firestore) - Flutter web

so i've tried to upload an image to firestore, but it gives me the error Unsupported operation: _Namespace. Here's my method:

File pickedImage;
  Future<Uri> uploadPic() async {
    FirebaseStorage _storage = FirebaseStorage.instance;

    StorageReference reference = _storage.ref().child("profile_pictures/");

    StorageUploadTask uploadTask = reference.putFile(pickedImage);

    Uri dowurl = await (await uploadTask.onComplete).ref.getDownloadURL();

    return dowurl; 
  }

Try adding a name to the file you want to save:

StorageReference reference = _storage.ref().child("profile_pictures/ –add Name here –");

You might also remove the / that comes after profile_pictures , if you don't want to add another reference

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM