Download Files with Capacitor 5

I recently upgrade Capacitor from 4 to 5 as well as my ionic version from 6 to 7. Previously in version 4 of Capacitor I was using @capacitor-community/http specifically the downloadFile method to download a video file from a URL. Well since upgrading on ios it works however on android it does not throwing the following error:

Attempt to invoke virtual method 'java.util.Iterator com.getcapacitor.JSObject.keys()' on a null object reference

I really don’t want to downgrade and want to use the most up to date versions but it seems though as the community/http will no longer be supported.

Any suggestions on how you’d go about downloading larger files from a URL?

@capacitor-community/http was replaced by the 1st party HTTP plugin. It looks like the new plugin doesn’t support large files yet but they do have a possible workaround that you could try mentioned under “Large File Support”.

I saw that and for what I’ve played with so far locally and on emulators its not consistent enough and I get way to many failed downloads depending on the android version.

@bradisrad83 Did you find any solutions to it?

Downloading files was added in @capacitor/filesystem@5.1.0 today :partying_face: :tada:.

The documentation is here.

1 Like

Do we need to install it separated, or is it already internal because i can see it in
import { Directory, Filesystem } from ‘@capacitor/filesystem’;

The thing is i notice there is already a version 5.1.2 Release @capacitor/filesystem@5.1.2 · ionic-team/capacitor-plugins · GitHub

Do you have a guide on how to use it?

Im trying to download a PDF from a link to the device