MatrixFile.fromMimeType constructor
derivatives the MIME type from the bytes
and correspondingly creates a
MatrixFile, MatrixImageFile, MatrixAudioFile or a MatrixVideoFile
Implementation
factory MatrixFile.fromMimeType(
{required Uint8List bytes, required String name, String? mimeType}) {
final msgType = msgTypeFromMime(mimeType ??
lookupMimeType(name, headerBytes: bytes) ??
'application/octet-stream');
if (msgType == MessageTypes.Image) {
return MatrixImageFile(bytes: bytes, name: name, mimeType: mimeType);
}
if (msgType == MessageTypes.Video) {
return MatrixVideoFile(bytes: bytes, name: name, mimeType: mimeType);
}
if (msgType == MessageTypes.Audio) {
return MatrixAudioFile(bytes: bytes, name: name, mimeType: mimeType);
}
return MatrixFile(bytes: bytes, name: name, mimeType: mimeType);
}