All file images are returning jpeg. How to solve this and get the correct MIME type.
Flutter doctor - no issues
Flutter 3.7.7
pubspec.yaml
...
image_picker: ^0.8.7+5
mime: ^1.0.4
...
Future<void> chooseImage() async {
var chosenImage = await _picker.pickImage(source: ImageSource.gallery);
if (chosenImage != null) {
setState(
() {
_tempFile = File(chosenImage.path);
},
);
} else {
// User canceled the picker
}
}
...
List<int> imageBytes = _tempFile!.readAsBytesSync();
String baseimage = base64Encode(imageBytes);
print(lookupMimeType(baseimage, headerBytes: [0xFF, 0xD8]));
...
If anyone had the same issue and could provide some insight it would be really appreciated. thanks.