firebase_download_example
firebase_download_example copied to clipboard
Files not downloading
when i click the download button it shows file downloaded but the file don't get downloaded and doesn't get save anywhere
@altmash5 I guess there is some issue in the downloadFile() Anyway I just changed it a little bit as I want my application to make its own directory in external storage if not created or just save the file in it if its already created so I did the following:
static Future downloadFile(Reference ref) async { Directory directory = await getExternalStorageDirectory(); String newPath = ""; print(directory); List<String> paths = directory.path.split("/"); for (int x = 1; x < paths.length; x++) { String folder = paths[x]; if (folder != "Android") { newPath += "/" + folder; } else { break; } } newPath = newPath + "/put in the name of directory you want to store the file in"; directory = Directory(newPath); File saveFile = File('${directory.path}/${ref.name}'); if (!await directory.exists()) { await directory.create(recursive: true); } if (await directory.exists()) { await ref.writeToFile(saveFile); } }
Thats it, Hope it helps.
@altmash5 I guess there is some issue in the downloadFile() Anyway I just changed it a little bit as I want my application to make its own directory in external storage if not created or just save the file in it if its already created so I did the following:
static Future downloadFile(Reference ref) async { Directory directory = await getExternalStorageDirectory(); String newPath = ""; print(directory); List paths = directory.path.split("/"); for (int x = 1; x < paths.length; x++) { String folder = paths[x]; if (folder != "Android") { newPath += "/" + folder; } else { break; } } newPath = newPath + "/put in the name of directory you want to store the file in"; directory = Directory(newPath); File saveFile = File('${directory.path}/${ref.name}'); if (!await directory.exists()) { await directory.create(recursive: true); } if (await directory.exists()) { await ref.writeToFile(saveFile); } }
Thats it, Hope it helps.
Hello there; Can you post the exact code screen? I couldn't add the code you wrote. Thanks.
For the black wipe out area write in the name of directory you want to store the file in
Here it is
Hope it helps