TF-725 Download inline image as base64 data
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:core/core.dart';
|
||||
@@ -26,4 +27,15 @@ class DownloadClient {
|
||||
|
||||
return (responseBody as ResponseBody);
|
||||
}
|
||||
|
||||
Future<String?> downloadImageAsBase64(String url) async {
|
||||
try {
|
||||
final response = await _dioClient.get(
|
||||
url,
|
||||
options: Options(responseType: ResponseType.bytes));
|
||||
return base64Encode(response);
|
||||
} catch (e) {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user