From 0125272b7e20f877d43949cb0e5ff893889b987e Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Wed, 22 Sep 2021 07:59:45 +0200 Subject: [PATCH] fix: Autodetect mimetype on file upload --- lib/src/client.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/src/client.dart b/lib/src/client.dart index 46b61586..602a3ab7 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -24,6 +24,7 @@ import 'dart:typed_data'; import 'package:http/http.dart' as http; import 'package:matrix/src/utils/run_in_root.dart'; +import 'package:mime/mime.dart'; import 'package:olm/olm.dart' as olm; import '../encryption.dart'; @@ -699,6 +700,7 @@ class Client extends MatrixApi { @override Future uploadContent(Uint8List file, {String filename, String contentType}) async { + contentType ??= lookupMimeType(filename ?? '', headerBytes: file); final mxc = await super .uploadContent(file, filename: filename, contentType: contentType); final storeable = database != null && file.length <= database.maxFileSize;