Improve created app file system structure on ios

This commit is contained in:
Anton Stubenbord
2023-02-14 22:46:26 +01:00
parent 42dbaaf855
commit ae31f59aa1
2 changed files with 13 additions and 3 deletions

View File

@@ -50,7 +50,10 @@ class FileService {
))! ))!
.first; .first;
} else if (Platform.isIOS) { } else if (Platform.isIOS) {
return getApplicationDocumentsDirectory(); final appDir = await getApplicationDocumentsDirectory();
final dir = Directory('${appDir.path}/documents');
dir.createSync();
return dir;
} else { } else {
throw UnsupportedError("Platform not supported."); throw UnsupportedError("Platform not supported.");
} }
@@ -67,7 +70,10 @@ class FileService {
} }
return directory; return directory;
} else if (Platform.isIOS) { } else if (Platform.isIOS) {
return getApplicationDocumentsDirectory(); final appDir = await getApplicationDocumentsDirectory();
final dir = Directory('${appDir.path}/downloads');
dir.createSync();
return dir;
} else { } else {
throw UnsupportedError("Platform not supported."); throw UnsupportedError("Platform not supported.");
} }
@@ -80,7 +86,10 @@ class FileService {
); );
return scanDir!.first; return scanDir!.first;
} else if (Platform.isIOS) { } else if (Platform.isIOS) {
return getApplicationDocumentsDirectory(); final appDir = await getApplicationDocumentsDirectory();
final dir = Directory('${appDir.path}/scans');
dir.createSync();
return dir;
} else { } else {
throw UnsupportedError("Platform not supported."); throw UnsupportedError("Platform not supported.");
} }

View File

@@ -91,6 +91,7 @@ class _DocumentDownloadButtonState extends State<DocumentDownloadButton> {
final createdFile = File(filePath); final createdFile = File(filePath);
createdFile.createSync(recursive: true); createdFile.createSync(recursive: true);
createdFile.writeAsBytesSync(bytes); createdFile.writeAsBytesSync(bytes);
debugPrint("Downloaded file to $filePath");
showSnackBar(context, S.of(context).documentDownloadSuccessMessage); showSnackBar(context, S.of(context).documentDownloadSuccessMessage);
} on PaperlessServerException catch (error, stackTrace) { } on PaperlessServerException catch (error, stackTrace) {
showErrorMessage(context, error, stackTrace); showErrorMessage(context, error, stackTrace);