TF-2628 Create open file in new browser tab function

This commit is contained in:
DatDang
2024-02-27 10:05:51 +07:00
committed by Dat H. Pham
parent bd401c12a2
commit 3bda85d919
@@ -104,6 +104,20 @@ class DownloadManager {
}
}
void openDownloadedFileWeb(Uint8List bytes, String? mimeType) {
try {
final blob = html.Blob([bytes], mimeType);
final url = html.Url.createObjectUrlFromBlob(blob);
html.window.open(url, '_blank');
html.Url.revokeObjectUrl(url);
} catch (exception) {
logError('DownloadManager::openDownloadedFileWeb(): ERROR: $exception');
rethrow;
}
}
MediaType? _extractMediaTypeFromResponse(ResponseBody responseBody) {
try {
final contentType = responseBody.headers[Headers.contentTypeHeader];