An open-source cross-platform alternative to AirDrop
fix: add mime fallback during file send
Tien Do Namba35b4824ed0
diff --git a/lib/model/dto/file_dto.dart b/lib/model/dto/file_dto.dartindex 76cba726..f3172f1d 100644--- a/lib/model/dto/file_dto.dart+++ b/lib/model/dto/file_dto.dart@@ -27,6 +27,8 @@ class FileDto {required this.legacy,});+ String lookupMime() => lookupMimeType(fileName) ?? 'application/octet-stream';+factory FileDto.fromJson(Map<String, Object?> json) => _parseFileDto(json);Map<String, dynamic> toJson() => _fileDtoToJson(this);@@ -89,7 +91,7 @@ Map<String, dynamic> _fileDtoToJson(FileDto instance) {'id': instance.id,'fileName': instance.fileName,'size': instance.size,- 'fileType': instance.legacy ? instance.fileType.name : (lookupMimeType(instance.fileName) ?? 'application/octet-stream'),+ 'fileType': instance.legacy ? instance.fileType.name : instance.lookupMime(),if (instance.hash != null)'hash': instance.hash,if (instance.preview != null)diff --git a/lib/provider/network/send_provider.dart b/lib/provider/network/send_provider.dartindex 59bdeb80..92d9ea18 100644--- a/lib/provider/network/send_provider.dart+++ b/lib/provider/network/send_provider.dart@@ -26,7 +26,6 @@ import 'package:localsend_app/provider/progress_provider.dart';import 'package:localsend_app/provider/selection/selected_sending_files_provider.dart';import 'package:localsend_app/provider/settings_provider.dart';import 'package:localsend_app/util/api_route_builder.dart';-import 'package:mime/mime.dart';import 'package:routerino/routerino.dart';import 'package:uuid/uuid.dart';@@ -280,7 +279,7 @@ class SendNotifier extends Notifier<Map<String, SendSessionState>> {options: Options(headers: {'Content-Length': file.file.size,- 'Content-Type': lookupMimeType(file.file.fileName),+ 'Content-Type': file.file.lookupMime(),},),data: file.path != null ? File(file.path!).openRead() : Stream.fromIterable([file.bytes!]),