1
0
mirror of https://github.com/immich-app/immich.git synced 2025-08-08 23:07:06 +02:00

fix(mobile): download asset to Camera folder on Android (#12355)

* fix(mobile): download asset to Camera folder on Android

* remove unused import

* better message

* linting
This commit is contained in:
Alex
2024-09-05 12:33:55 -05:00
committed by GitHub
parent 0148005931
commit 77904a54d8
4 changed files with 26 additions and 18 deletions

View File

@ -19,7 +19,7 @@ class ImageViewerService {
ImageViewerService(this._apiService);
Future<bool> downloadAssetToDevice(Asset asset) async {
Future<bool> downloadAsset(Asset asset) async {
File? imageFile;
File? videoFile;
try {
@ -82,18 +82,23 @@ class ImageViewerService {
}
final AssetEntity? entity;
final relativePath = Platform.isAndroid ? 'DCIM/Immich' : null;
if (asset.isImage) {
entity = await PhotoManager.editor.saveImage(
res.bodyBytes,
title: asset.fileName,
relativePath: relativePath,
);
} else {
final tempDir = await getTemporaryDirectory();
videoFile = await File('${tempDir.path}/${asset.fileName}').create();
videoFile.writeAsBytesSync(res.bodyBytes);
entity = await PhotoManager.editor
.saveVideo(videoFile, title: asset.fileName);
entity = await PhotoManager.editor.saveVideo(
videoFile,
title: asset.fileName,
relativePath: relativePath,
);
}
return entity != null;
}