At the moment i build a chat similar in wahtsapp. I would like upload some local files (pdf, txt, image...).
Like this:
I try to get the local files via path_provider. But i dont get access to download folder.
My problem: I don't know how i can access the dowload folder with path_provider.
See my code:
//load local files from download folder
_loadLocalFile() async {
//absoulute path to download file
var file = io.Directory('/storage/emulated/0/Download/')
.listSync(); //use your folder name insted of resume.
//console output -> []
//other try to get download folder
List<io.Directory>? documents = await getExternalStorageDirectories();
//console output -> [Directory: '/storage/emulated/0/Android/data/de.securebuy.securebuy/files', Directory: '/storage/1BEC-0908/Android/data/de.securebuy.securebuy/files']
print(documents.toString());
}
I also add to AndroidManifest following rules:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE”/>
Anyone have a idea how i can build a function similar in image? Is that possible?
Many thx
CodePudding user response:
till now , pathprovider
isn't going to let you in downloads file , so if you are on android you can just write the downloads directory , else using android_path_provider
it is a null-safety package and you can accsess it via :var downloadsPath = await AndroidPathProvider.downloadsPath;
, on ios you can get only the app directory cuase ios makes it's own file for every app thus we use 'pathprovider' with Directory appDocDir = await getApplicationDocumentsDirectory();
Update :
i see what you are trying to achieve and this is not what pathprovider
pcakage is used for , you have to use file_picker
, read thier docs , i thinks that this is what you need