From a237fba4823e451c40f8c902511d7e57bb7e8438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20M=C3=BCller?= Date: Sun, 17 Sep 2023 09:56:15 +0200 Subject: [PATCH] Fixed encoding problems when downloading displaying/ downloading files with special characters --- .../webdav/queries/listFiles/cacheableFile.dart | 2 +- lib/view/pages/files/fileElement.dart | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/api/marianumcloud/webdav/queries/listFiles/cacheableFile.dart b/lib/api/marianumcloud/webdav/queries/listFiles/cacheableFile.dart index 5f0acf9..c6f1491 100644 --- a/lib/api/marianumcloud/webdav/queries/listFiles/cacheableFile.dart +++ b/lib/api/marianumcloud/webdav/queries/listFiles/cacheableFile.dart @@ -24,7 +24,7 @@ class CacheableFile { CacheableFile.fromDavFile(WebDavFile file) { path = file.path; isDirectory = file.isDirectory; - name = file.name; + name = file.isDirectory ? file.name : file.path.split("/").last; mimeType = file.mimeType; size = file.size; eTag = file.etag; diff --git a/lib/view/pages/files/fileElement.dart b/lib/view/pages/files/fileElement.dart index 4c687e1..bb18be6 100644 --- a/lib/view/pages/files/fileElement.dart +++ b/lib/view/pages/files/fileElement.dart @@ -24,6 +24,9 @@ class FileElement extends StatefulWidget { static Future download(BuildContext context, String remotePath, String name, Function(double) onProgress, Function(OpenResult) onDone) async { Directory paths = await getTemporaryDirectory(); + + var encodedPath = Uri.encodeComponent(remotePath); + encodedPath = encodedPath.replaceAll("%2F", "/"); String local = paths.path + Platform.pathSeparator + name; @@ -46,7 +49,7 @@ class FileElement extends StatefulWidget { ); return await Flowder.download( - "${await WebdavApi.webdavConnectString}$remotePath", + "${await WebdavApi.webdavConnectString}$encodedPath", options, ); }