diff --git a/example/ios/Flutter/.last_build_id b/example/ios/Flutter/.last_build_id index 20c7c514..3c74be76 100644 --- a/example/ios/Flutter/.last_build_id +++ b/example/ios/Flutter/.last_build_id @@ -1 +1 @@ -c3e639ccf9b069e37a7d1345194e6b99 \ No newline at end of file +be54eb19d957de3aac70eae5513f67ef \ No newline at end of file diff --git a/example/pubspec.yaml b/example/pubspec.yaml index e84b2303..5e7cc348 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -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" diff --git a/lib/src/message_input.dart b/lib/src/message_input.dart index d3522a91..9bcddf05 100644 --- a/lib/src/message_input.dart +++ b/lib/src/message_input.dart @@ -1623,14 +1623,7 @@ class MessageInputState extends State { Future _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 { 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 _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;