chore: use foreground service for uploading large file on Android (#21095)

* chore: use foreground service for uploading large file on Android

* Update main.dart

Co-authored-by: shenlong <139912620+shenlong-tanwen@users.noreply.github.com>

* Update mobile/lib/main.dart

Co-authored-by: shenlong <139912620+shenlong-tanwen@users.noreply.github.com>

---------

Co-authored-by: shenlong <139912620+shenlong-tanwen@users.noreply.github.com>
This commit is contained in:
Alex
2025-08-20 12:29:24 -05:00
committed by GitHub
parent a1beb0a87d
commit 0e7816130b
2 changed files with 11 additions and 2 deletions

View File

@@ -94,7 +94,9 @@ Future<void> initApp() async {
// Initialize the file downloader
await FileDownloader().configure(
// maxConcurrent: 6, maxConcurrentByHost(server):6, maxConcurrentByGroup: 3
globalConfig: (Config.holdingQueue, (6, 6, 3)),
// On Android, if files are larger than 256MB, run in foreground service
globalConfig: [(Config.holdingQueue, (6, 6, 3)), (Config.runInForegroundIfFileLargerThan, 256)],
);
await FileDownloader().trackTasksInGroup(kDownloadGroupLivePhoto, markDownloadedComplete: false);
@@ -182,6 +184,13 @@ class ImmichAppState extends ConsumerState<ImmichApp> with WidgetsBindingObserve
complete: TaskNotification('upload_finished'.tr(), '${'file_name'.tr()}: {displayName}'),
progressBar: true,
);
FileDownloader().configureNotificationForGroup(
kBackupGroup,
running: TaskNotification('uploading_media'.tr(), '${'file_name'.tr()}: {displayName}'),
complete: TaskNotification('upload_finished'.tr(), '${'file_name'.tr()}: {displayName}'),
progressBar: true,
);
}
Future<DeepLink> _deepLinkBuilder(PlatformDeepLink deepLink) async {