-
Notifications
You must be signed in to change notification settings - Fork 135
downloadFile function is not working on Capacitor 3 #142
Comments
As issue #135 (comment) states, just add the method to your downloadFile call. Example: Regards |
Can you provide a small github repo that is reproduction of your bug? |
Hi @thomasvidas, |
Hi ! The same error here ! |
Any update on this yet. I am still stuck with this and not able to go ahead with the capacitor upgrade. Please help. |
Have IO Error on android too |
const httpOptions: HttpDownloadFileOptions = {
url: normalImageUrlThatWorksOnIOS
fileDirectory: Directory.Cache,
filePath: normalImageNameThatWorksOnIOS,
};
const resp = await Http.downloadFile(httpOptions); Getting - IO Error Error jumps to the code line const storedCall = callbacks.get(result.callbackId);
if (storedCall) {
// looks like we've got a stored call
if (result.error) {
// ensure stacktraces by copying error properties to an Error
result.error = Object.keys(result.error).reduce((err, key) => {
// use any type to avoid importing util and compiling most of .ts files
err[key] = result.error[key];
return err;
}, new cap.Exception(''));
}
if (typeof storedCall.callback === 'function') {
// callback <----- here ist he error line for me
if (result.success) {
storedCall.callback(result.data);
}
else {
storedCall.callback(null, result.error);
}
} |
If it helps anyone, I managed to solve the IO error while downloading files on Android using capacitor 3 (that worked fine on iOS). My specific issue was that I was attempting to download a file to a sub folder without having created the sub folder first. It was erroring out for me in the java side; Example:
this would fail and return
|
Making dir beforehand doesn't solve IO Error for me. Im on Android 9 |
I am also getting the IO error, creating the directory beforehand did not resolve it for me either. |
I've got this error in android logs:
I've figured out that you can use "DOWNLOADS" as forlder on Android 11+ but on android 10 throws the above error. |
Just wanted to follow up and say the IO Error I was getting was an interrupt to the IO Stream, which was caused by me trying to run Http.downloadFile() multiple times asynchronously. |
Hi everybody! |
Try running your application outside of the android studio emulator. I found the error was only present in the emulator. |
@ericmoolin im not sure if it is the case. The emulator Android version must match with the live device. It can be the case of - my real device has different Android version and I no longer encounter issues that I have on emulators. |
Any news on that. It's defo a permission issue. Anybody would have a solution to open PDF. Thanks. |
I've used this package https://github.com/agorapulse/capacitor-mediastore for Android 10 and lower as a workaround. |
"DOWNLOADS" is not in documentation but I figured out from java source code and it worked for me
Although it's not quite relevant to this issue, I tried https://ionicframework.com/docs/native/file-opener and it works for Capacitor 3 as well
it doesn't have to, IMHO. |
Thanks nikage for the quick reply. Much appreciate.
Default not working on grade 8 File Opener not working because Capacitor/Cordova Android plugin is using jcenter() And Grade 8 has deprecate it.
I have try to replace jcenter() to mavenCentral() but the plugin change it back on build. Thanks again nikage. |
I too have been having issues with |
Hi There,
downloadFile() function is not working on Capacitor 3
It was working fine with Capacitor 2, but it started failing after upgrading to Capacitor 3. Please see the below screenshot.
Screenshots
I am testing this on Android 10.
Please look into the issue. Thanks for your help.
The text was updated successfully, but these errors were encountered: