Currently, file messages containing files with types not found in the mime library using lookupMimeType(file)
are not sent. This includes both HEIC and HEIF file types, the default on many IOS devices. This could be fixed by checking header bytes for file types which can be done with the mime library.
in file file_message_params.dart:
FileMessageParams.withFile(File file, {String? name})
: uploadFile = FileInfo.fromData(
name: name ?? 'my_file',
file: file,
mimeType: lookupMimeType(file.path),
);
could be changed to
FileMessageParams.withFile(File file, {String? name})
: uploadFile = FileInfo.fromData(
name: name ?? 'my_file',
file: file,
mimeType: lookupMimeType(file.path, headerBytes: [0xFF, 0xD8]),
);
It might be helpful to refactor to force mimeType
to be a non-null member so it throws when a file that can’t send is passed in. The current behavior is onComplete
is never called. So it appears as if it is trying to send indefinitely.