TF-2602 Set charset for attachment with mimeType=text/plain when sent email on web
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:core/data/network/dio_client.dart';
|
||||
import 'package:core/data/network/download/download_client.dart';
|
||||
import 'package:core/utils/application_manager.dart';
|
||||
import 'package:core/utils/file_utils.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:jmap_dart_client/http/http_client.dart';
|
||||
import 'package:tmail_ui_user/features/base/base_bindings.dart';
|
||||
@@ -38,7 +39,10 @@ class PublicAssetBindings extends BaseBindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(
|
||||
() => FileUploader(Get.find<DioClient>(tag: BindingTag.isolateTag), Get.find<Executor>()),
|
||||
() => FileUploader(
|
||||
Get.find<DioClient>(tag: BindingTag.isolateTag),
|
||||
Get.find<Executor>(),
|
||||
Get.find<FileUtils>()),
|
||||
tag: BindingTag.publicAssetBindingsTag);
|
||||
Get.lazyPut(
|
||||
() => PublicAssetApi(Get.find<HttpClient>(), Get.find<Uuid>()),
|
||||
|
||||
@@ -123,11 +123,13 @@ class FileUploader {
|
||||
);
|
||||
log('FileUploader::_handleUploadAttachmentAction(): RESULT_JSON = $resultJson');
|
||||
if (argsUpload.mobileFileUpload.mimeType == FileUtils.TEXT_PLAIN_MIME_TYPE) {
|
||||
final fileCharset = await argsUpload.fileUtils.getFileCharset(argsUpload.mobileFileUpload.filePath);
|
||||
final fileCharset = await argsUpload.fileUtils.getCharsetFromBytes(
|
||||
File(argsUpload.mobileFileUpload.filePath).readAsBytesSync()
|
||||
);
|
||||
return _parsingResponse(
|
||||
resultJson: resultJson,
|
||||
fileName: argsUpload.mobileFileUpload.fileName,
|
||||
fileCharset: fileCharset);
|
||||
fileCharset: fileCharset.toLowerCase());
|
||||
} else {
|
||||
return _parsingResponse(
|
||||
resultJson: resultJson,
|
||||
@@ -140,7 +142,7 @@ class FileUploader {
|
||||
requestOptions: exception.requestOptions.copyWith(data: ''));
|
||||
} catch (exception) {
|
||||
logError('FileUploader::_handleUploadAttachmentAction():OtherException: $exception');
|
||||
|
||||
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
@@ -181,8 +183,18 @@ class FileUploader {
|
||||
);
|
||||
}
|
||||
);
|
||||
log('FileUploader::_handleUploadAttachmentActionOnWeb():resultJson: $resultJson');
|
||||
return _parsingResponse(resultJson: resultJson, fileName: fileInfo.fileName);
|
||||
log('FileUploader::_handleUploadAttachmentActionOnWeb(): RESULT_JSON = $resultJson');
|
||||
if (fileInfo.mimeType == FileUtils.TEXT_PLAIN_MIME_TYPE) {
|
||||
final fileCharset = await _fileUtils.getCharsetFromBytes(fileInfo.bytes!);
|
||||
return _parsingResponse(
|
||||
resultJson: resultJson,
|
||||
fileName: fileInfo.fileName,
|
||||
fileCharset: fileCharset.toLowerCase());
|
||||
} else {
|
||||
return _parsingResponse(
|
||||
resultJson: resultJson,
|
||||
fileName: fileInfo.fileName);
|
||||
}
|
||||
}
|
||||
|
||||
static Attachment _parsingResponse({
|
||||
|
||||
Reference in New Issue
Block a user