2022-09-09 18:29:33 +02:00
|
|
|
import 'package:nc_photos/account.dart';
|
|
|
|
import 'package:nc_photos/api/api_util.dart' as api_util;
|
|
|
|
import 'package:nc_photos/cache_manager_util.dart';
|
2023-04-13 17:32:31 +02:00
|
|
|
import 'package:nc_photos/entity/file_descriptor.dart';
|
2022-09-09 18:29:33 +02:00
|
|
|
import 'package:nc_photos/k.dart' as k;
|
2023-02-23 15:49:17 +01:00
|
|
|
import 'package:nc_photos/np_api_util.dart';
|
2022-09-09 18:29:33 +02:00
|
|
|
import 'package:nc_photos/platform/k.dart' as platform_k;
|
|
|
|
import 'package:nc_photos_plugin/nc_photos_plugin.dart';
|
|
|
|
|
|
|
|
class DownloadPreview {
|
2023-04-13 17:32:31 +02:00
|
|
|
Future<dynamic> call(Account account, FileDescriptor file) async {
|
2022-09-09 18:29:33 +02:00
|
|
|
assert(platform_k.isAndroid);
|
|
|
|
final previewUrl = api_util.getFilePreviewUrl(
|
|
|
|
account,
|
|
|
|
file,
|
|
|
|
width: k.photoLargeSize,
|
|
|
|
height: k.photoLargeSize,
|
2022-12-18 07:35:54 +01:00
|
|
|
isKeepAspectRatio: true,
|
2022-09-09 18:29:33 +02:00
|
|
|
);
|
|
|
|
final fileInfo =
|
|
|
|
await LargeImageCacheManager.inst.getSingleFile(previewUrl, headers: {
|
2023-02-23 15:49:17 +01:00
|
|
|
"authorization": AuthUtil.fromAccount(account).toHeaderValue(),
|
2022-09-09 18:29:33 +02:00
|
|
|
});
|
|
|
|
return ContentUri.getUriForFile(fileInfo.absolute.path);
|
|
|
|
}
|
|
|
|
}
|