Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Files not downloading #2

Open
altmash5 opened this issue Oct 26, 2021 · 3 comments
Open

Files not downloading #2

altmash5 opened this issue Oct 26, 2021 · 3 comments

Comments

@altmash5
Copy link

when i click the download button it shows file downloaded but the file don't get downloaded and doesn't get save anywhere

@Abhijit-007a
Copy link

Abhijit-007a commented Oct 29, 2021

@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.

@ayzek67
Copy link

ayzek67 commented Oct 29, 2021

@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.

@Abhijit-007a
Copy link

Abhijit-007a commented Oct 30, 2021

image
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants