Flutter - Where should I save downloaded files? - flutter

I am building a flutter app (iOS/Android/MacOS/Windows/Web) which is able to download files, selected by the user. But where should I save those files? On MacOS/Windows its easy using path_provider and get the path of the downloads folder.
But where should I save the files on the other platforms? The downloads folder would be perfect because the users are able to use those files (.pdf) even without using the app, so the files are not app specific.

If you wish to save in download directory you can use
Directory appDownloadDir = await getDownloadsDirectory();
String appDownloadPath = appDownloadDir.path;
Or
getExternalStorageDirectory()//android
getApplicationDocumentsDirectory()// ios doesnt support access to download folder

Related

How can I save a local file into assets folder in Flutter

My flutter desktop application takes a local file (audio/video/image) as user input. Now I need to save it to somewhere for later usage. So that even if the device changes the application can still access them using relative path.
What I want to do is copy this file to assets folder using file.copy method. But how can I get the assets folder's directory? I don't want to hardcode assets folder's absolute path. Is there any way to copy files into assets folder using relative path?
Or any alternate way to do the task?
assets is read-only. Use documents directory where the application can store files that only it can access.
final directory = await getApplicationDocumentsDirectory();
See Read and write files for details.

Is it possible to create a password-protected ZIP file with Flutter / Dart?

I would like to create a ZIP file that is protected with a password.
Has anyone done this before and can you give me a few tips? I couldn't find a reasonable package on pub.dev.
Plugin archive
https://pub.dev/packages/archive
Use this plugin you can do like this:
final archive = ZipDecoder().decodeBytes(
_file,
verify: true,
password: "your_password", )
You can use this unpublished plugin flutter_zip_archive just download the code and use it. For better future development add the method channels from the repo to your app with the files included in the lib folder.
This package supports zipping and unzipping the files with passwords. It also provides the privilege of adding the destination where the zip file should be stored.
PS. To encrypt a file you'll need a file available locally before zipping.

How do I save files downloaded in my app to Downloads folder in Files app in Swift 4.2?

Is it possible to save the files downloaded from my app to be stored in the Downloads folder in Files App?
I am successful in creating my app folder in "On My iPhone" in Files and saving the files there.
However, my requirement is to save it in the Downloads folder in Files.
Is this possible? If so, how do I achieve this?

Deploy files in the localState folder during installation of a store app

I am building an app for windows store and I need some default and example data to be in the localstate folder (Windows.Storage.ApplicationData.current.localFolder) when the app run the first time.
The folder and files structure is a bit complex and I tryed to copy the files at the start of the application, but I can't manage that way.
Is it possible to have files being copied automatically from the installation folder to the localstate folder during the store app installation?
Unfortunately, customization of the app install process isn't currently supported. You have to do this as part of your first run processing.
One possibility is that you include the data in your package as a .ZIP or other compressed file and use an appropriate library to expand that file into a folder structure on startup. That could simplify your logic considerably. (I don't have a library to recommend; it's just an idea.)

when i am adding folder from other app to my app am getting error like no such file or directory

i am adding folder from other app folder and then put that folder in my app and i import folder files to my app file but i am getting error like no such file or directory while running.
If you're attempting to move folders between running iPhone applications, you can't because of the application sandbox that isolates the applications from each other.
If you're attempting to add files and folders to an Xcode project, you need to make sure they are added to the appropriate target. If they are resources like images, sounds, plist etc you must have Xcode copy them to the project folder to ensure they are included in the final product.