TF-296 Fix download file on browser
This commit is contained in:
@@ -27,6 +27,13 @@ abstract class EmailDataSource {
|
||||
CancelToken cancelToken
|
||||
);
|
||||
|
||||
Future<bool> downloadAttachmentForWeb(
|
||||
Attachment attachment,
|
||||
AccountId accountId,
|
||||
String baseDownloadUrl,
|
||||
AccountRequest accountRequest,
|
||||
);
|
||||
|
||||
Future<List<EmailId>> moveToMailbox(AccountId accountId, MoveRequest moveRequest);
|
||||
|
||||
Future<List<Email>> markAsStar(
|
||||
|
||||
@@ -113,4 +113,13 @@ class EmailDataSourceImpl extends EmailDataSource {
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> downloadAttachmentForWeb(Attachment attachment, AccountId accountId, String baseDownloadUrl, AccountRequest accountRequest) {
|
||||
return Future.sync(() async {
|
||||
return await emailAPI.downloadAttachmentForWeb(attachment, accountId, baseDownloadUrl, accountRequest);
|
||||
}).catchError((error) {
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -202,6 +202,19 @@ class EmailAPI {
|
||||
cancelToken: cancelToken);
|
||||
}
|
||||
|
||||
Future<bool> downloadAttachmentForWeb(
|
||||
Attachment attachment,
|
||||
AccountId accountId,
|
||||
String baseDownloadUrl,
|
||||
AccountRequest accountRequest,
|
||||
) async {
|
||||
return _downloadManager.downloadFileForWeb(
|
||||
attachment.getDownloadUrl(baseDownloadUrl, accountId),
|
||||
attachment.name ?? '',
|
||||
accountRequest.basicAuth,
|
||||
);
|
||||
}
|
||||
|
||||
Future<List<EmailId>> moveToMailbox(AccountId accountId, MoveRequest moveRequest) async {
|
||||
final setEmailMethod = SetEmailMethod(accountId)
|
||||
..addUpdates(moveRequest.emailIds
|
||||
|
||||
@@ -103,4 +103,9 @@ class EmailRepositoryImpl extends EmailRepository {
|
||||
Future<Email?> updateEmailDrafts(AccountId accountId, Email newEmail, EmailId oldEmailId) {
|
||||
return emailDataSource.updateEmailDrafts(accountId, newEmail, oldEmailId);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> downloadAttachmentForWeb(Attachment attachment, AccountId accountId, String baseDownloadUrl, AccountRequest accountRequest) {
|
||||
return emailDataSource.downloadAttachmentForWeb(attachment, accountId, baseDownloadUrl, accountRequest);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user