WebP image uploads as application/octet-stream file. Firebase/Flutter

Viewed 484

I'm working on uploading images to firebase storage, and if the image type is webp it false into firebase as an application/octet-stream file.

Is there any way to upload webp files to firebase? or How can I detect webp files before uploading?(refer to the snippet below)

Uploading to Firebase:

 for (final image in _imageList) {
  String path = image.path;
  print(path);
  final Reference _ref = FirebaseStorage.instance
      .ref()
      .child("image.path");

  UploadTask uploadTask = _ref.putFile(image as i.File);
  await uploadTask.whenComplete(() async {
    print("***Image Uploaded***");
    String image_Links = await _ref.getDownloadURL();
    _imageUrls.add(image_Links);
  });
}

Images selected via ImagePicker:

Future _getImage() async {
var image_file = await ImagePicker.pickImage(source: ImageSource.gallery);
setState(() {
  _imageFile = image_file;
  _imageList.insert(0, _imageFile);
});
}

I've tried getting the image file path to prevent the user from selecting webp files:

 String baseName = _imageFile.path.split('/').last;
                    print(baseName);// output - (image_picker1664504931971029294.jpg)

but it turns out that all the files selected via ImagePicker transforms into 'jpg' format. (and falls into firebase as the original format)

0 Answers
Related