I am trying to copy a music file from my app to the Music folder in the storage. If I try to copy to Download folder it works fine. What I am missing?
This works fine:
final musicFolderPath = '/storage/emulated/0/Download';
This do not work:
final musicFolderPath = '/storage/emulated/0/Music';
Related
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
how to get access to the path directory in FLUTTER WEB as final dir = await getApplicationDocumentsDirectory(); doesn't seem to work ... This is required to generate pdf invoice.
The web does not have internal file storage or acces a device,
information can only be stored through cookies or a database such as
Indexeddb.
You can create the invoice by creating the file with dart code and then send it or share it by some means
Another way would be to create it through a canvas.
i just uploaded the file to fireStore and then fetched it then again launched it using http package. or i found out we can launch the url also with launcher package.
I'm writing a flutter app in which I want to download files from an URL when I write this URL in my browser the file download
I want to do the same with flutter and I want to store the file in the phone local storage
I tried with dio and path provider without any result it show me that the file is downloaded but I do not find it in local storage this is my method
Future <void> dow5tn()async{
var dir=await getApplicationDocumentsDirectory();
Dio dio=Dio();
dio.download('http://192.168.43.24:27017/api/posts/uknoww','${dir.path}/filename.pdf');
}
Try this GitHub Repos
It's work for me
I copy image from gallery to app directory like this:
file.copy("${(await getApplicationDocumentsDirectory()).path}/media/foo.jpg");
And it works. But when i restart app, file dissappears.
So how should i save images to keep them even after app restart?
The problem was in my other code. I was trying to copy file to the same path and it didn't work properly. So, I added if check and it resolved problem.
if(file.path != newPath){
await file.copy(newPath);
}
I have developed an application which read text file. In Emulator I have push the file in
\Data\Data\PackageName\File.txt and its working fine. But when I try to push file in Device its generate the error Read Only File System. I have try to remount directory as writable but the same error. Please help me how can I push file into device.
The folder you are trying is locked on non-rooted phones i.e no write permission and I guess the device you are trying on is not a rooted one. since emulator is sort of developer device which is said to be rooted that's why you can push file to that location.
So depending on your requirement you have to either use Assest folder or File system storage
Update: How to use assest folder
Resources r = getResources();
AssetManager assetManager = r.getAssets();
InputStream in = assetManager.open(filename);
In practice, we can push such file in assets folder. Assets folder is there for you to put such raw files to be used inside the application.