TF-2602 Set charset for attachment with mimeType=text/plain when sent email on web

This commit is contained in:
dab246
2024-02-26 13:13:11 +07:00
committed by Dat H. Pham
parent 514bc578ec
commit 2739a284d8
12 changed files with 101 additions and 49 deletions
+6 -7
View File
@@ -9,7 +9,7 @@ import 'package:flutter_charset_detector/flutter_charset_detector.dart';
import 'package:path_provider/path_provider.dart';
class FileUtils {
static const String DEFAULT_CHARSET = 'UTF-8';
static const String DEFAULT_CHARSET = 'uft-8';
static const String TEXT_PLAIN_MIME_TYPE = 'text/plain';
Future<String> _getInternalStorageDirPath({
@@ -139,14 +139,13 @@ class FileUtils {
}
}
Future<String> getFileCharset(String filePath) async {
Future<String> getCharsetFromBytes(Uint8List bytes) async {
try {
final file = File(filePath);
final decodingResult = await CharsetDetector.autoDecode(file.readAsBytesSync());
logError('FileUtils::getFileCharset: FILE_CHARSET = ${decodingResult.charset}');
return decodingResult.charset;
final decodedResult = await CharsetDetector.autoDecode(bytes);
log('FileUtils::getCharsetFromBytes: FILE_CHARSET = ${decodedResult.charset}');
return decodedResult.charset;
} catch (e) {
logError('FileUtils::getFileCharset: Exception: $e');
logError('FileUtils::getCharsetFromBytes: Exception: $e');
return DEFAULT_CHARSET;
}
}
@@ -1,4 +1,4 @@
import 'dart:js' as js;
import 'package:universal_html/js.dart' as js;
/// Whether the CanvasKit renderer is being used on web.
///
+14 -6
View File
@@ -330,10 +330,10 @@ packages:
dependency: "direct main"
description:
name: flutter_charset_detector
sha256: "45de8a4b4255c1ea850a30955e7456091899ed4ff8b75593e14ec59f629b4b56"
sha256: "5d4796d43dac2f37e14149b0f0c676fa08e8eb1ada8e99342a838d971d2fb9b1"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
version: "3.0.0"
flutter_charset_detector_android:
dependency: transitive
description:
@@ -342,14 +342,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.1"
flutter_charset_detector_ios:
flutter_charset_detector_darwin:
dependency: transitive
description:
name: flutter_charset_detector_ios
sha256: e0e2c7b819cd1f7c9a50da94bf7f0e6d7a095eb64e81196ec758e77793903d43
name: flutter_charset_detector_darwin
sha256: d17c1847366a0501449d95d18a43417585841afe10200ceefb4422e6b7fccefb
url: "https://pub.dev"
source: hosted
version: "1.0.2"
version: "1.0.0"
flutter_charset_detector_platform_interface:
dependency: transitive
description:
@@ -358,6 +358,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.0"
flutter_charset_detector_web:
dependency: transitive
description:
name: flutter_charset_detector_web
sha256: d8495115abada771c75f9395aae3e5809ffd506e8fc8f62b403ae11fc29e1d2b
url: "https://pub.dev"
source: hosted
version: "1.0.2"
flutter_image_compress:
dependency: "direct main"
description:
+1 -1
View File
@@ -79,7 +79,7 @@ dependencies:
fk_user_agent: 2.1.0
flutter_charset_detector: 2.0.0
flutter_charset_detector: 3.0.0
dev_dependencies:
flutter_test: