nc-photos/app/lib/mobile/file_saver.dart

20 lines
575 B
Dart
Raw Normal View History

2021-09-09 22:42:47 +02:00
import 'dart:typed_data';
import 'package:nc_photos/platform/file_saver.dart' as itf;
import 'package:nc_photos/platform/k.dart' as platform_k;
2022-05-03 12:44:48 +02:00
import 'package:nc_photos_plugin/nc_photos_plugin.dart';
2021-09-09 22:42:47 +02:00
class FileSaver extends itf.FileSaver {
@override
saveFile(String filename, Uint8List content) {
if (platform_k.isAndroid) {
return _saveFileAndroid(filename, content);
} else {
throw UnimplementedError();
}
}
Future<String> _saveFileAndroid(String filename, Uint8List content) =>
2022-05-03 12:44:48 +02:00
MediaStore.saveFileToDownload(content, filename);
2021-09-09 22:42:47 +02:00
}