fix(ui): use file extension instead of mimeType

This commit is contained in:
Salvatore Giordano
2021-12-16 10:17:42 +01:00
parent 536fb45d5b
commit a5005bb78f
@@ -365,12 +365,13 @@ class AttachmentActionsModal extends StatelessWidget {
}) async { }) async {
String? filePath; String? filePath;
final appDocDir = await getTemporaryDirectory(); final appDocDir = await getTemporaryDirectory();
final url =
attachment.assetUrl ?? attachment.imageUrl ?? attachment.thumbUrl!;
await Dio().download( await Dio().download(
attachment.assetUrl ?? attachment.imageUrl ?? attachment.thumbUrl!, url,
(Headers responseHeaders) { (Headers responseHeaders) {
final contentType = responseHeaders[Headers.contentTypeHeader]!; final ext = Uri.parse(url).pathSegments.last;
final mimeType = contentType.first.split('/').last; filePath ??= '${appDocDir.path}/${attachment.id}.$ext';
filePath ??= '${appDocDir.path}/${attachment.id}.$mimeType';
return filePath!; return filePath!;
}, },
onReceiveProgress: progressCallback, onReceiveProgress: progressCallback,