Merge pull request #2046 from famedly/karthi/mimetype

fix: incorrect mimeType for files when downloading
This commit is contained in:
Krille-chan 2025-03-11 12:42:38 +01:00 committed by GitHub
commit 571e0369d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 4 deletions

View File

@ -792,7 +792,11 @@ class Event extends MatrixEvent {
throw ('Unable to decrypt file');
}
}
return MatrixFile(bytes: uint8list, name: body);
return MatrixFile(
bytes: uint8list,
name: body,
mimeType: attachmentMimetype,
);
}
/// Returns if this is a known event type.

View File

@ -41,8 +41,9 @@ class MatrixFile {
}
MatrixFile({required this.bytes, required String name, String? mimeType})
: mimeType = mimeType ??
lookupMimeType(name, headerBytes: bytes) ??
: mimeType = mimeType != null && mimeType.isNotEmpty
? mimeType
: lookupMimeType(name, headerBytes: bytes) ??
'application/octet-stream',
name = name.split('/').last;