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

20 lines
592 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;
2022-05-03 12:44:48 +02:00
import 'package:nc_photos_plugin/nc_photos_plugin.dart';
2023-08-27 12:58:05 +02:00
import 'package:np_platform_util/np_platform_util.dart';
2021-09-09 22:42:47 +02:00
class FileSaver extends itf.FileSaver {
@override
saveFile(String filename, Uint8List content) {
2023-08-27 12:58:05 +02:00
if (getRawPlatform() == NpPlatform.android) {
2021-09-09 22:42:47 +02:00
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
}