fix mimetype of .heic pics when picked from files
This commit is contained in:
@@ -1 +1 @@
|
||||
c3e639ccf9b069e37a7d1345194e6b99
|
||||
be54eb19d957de3aac70eae5513f67ef
|
||||
@@ -1,6 +1,6 @@
|
||||
name: example
|
||||
description: A new Flutter project.
|
||||
version: 1.0.85+87
|
||||
version: 1.0.86+88
|
||||
|
||||
environment:
|
||||
sdk: ">=2.2.2 <3.0.0"
|
||||
|
||||
@@ -1623,14 +1623,7 @@ class MessageInputState extends State<MessageInput> {
|
||||
|
||||
Future<String> _uploadImage(PlatformFile file, Channel channel) async {
|
||||
final filename = file.name ?? file.path?.split('/')?.last;
|
||||
httpParser.MediaType mimeType;
|
||||
if (filename != null) {
|
||||
if (filename.toLowerCase().endsWith('heic')) {
|
||||
mimeType = httpParser.MediaType.parse('image/heic');
|
||||
} else {
|
||||
mimeType = httpParser.MediaType.parse(lookupMimeType(filename));
|
||||
}
|
||||
}
|
||||
final mimeType = _getMimeType(filename);
|
||||
final bytes = file.bytes;
|
||||
final res = await channel.sendImage(
|
||||
MultipartFile.fromBytes(
|
||||
@@ -1642,14 +1635,28 @@ class MessageInputState extends State<MessageInput> {
|
||||
return res.file;
|
||||
}
|
||||
|
||||
httpParser.MediaType _getMimeType(String filename) {
|
||||
httpParser.MediaType mimeType;
|
||||
if (filename != null) {
|
||||
if (filename.toLowerCase().endsWith('heic')) {
|
||||
mimeType = httpParser.MediaType.parse('image/heic');
|
||||
} else {
|
||||
mimeType = httpParser.MediaType.parse(lookupMimeType(filename));
|
||||
}
|
||||
}
|
||||
|
||||
return mimeType;
|
||||
}
|
||||
|
||||
Future<String> _uploadFile(PlatformFile file, Channel channel) async {
|
||||
final filename = file.name ?? file.path?.split('/')?.last;
|
||||
final mimeType = _getMimeType(filename);
|
||||
final bytes = file.bytes;
|
||||
final res = await channel.sendFile(
|
||||
MultipartFile.fromBytes(
|
||||
bytes,
|
||||
filename: filename,
|
||||
contentType: httpParser.MediaType.parse(lookupMimeType(filename)),
|
||||
contentType: mimeType,
|
||||
),
|
||||
);
|
||||
return res.file;
|
||||
|
||||
Reference in New Issue
Block a user