Why is there no clear guide on downloading files with Capacitor?

This seems like incredibly basic functionality and I’ve been going in circles for a day now trying to find how I’m supposed to properly download files from within our app.

Is there an up-to-date suggested method and or an up-to-date guide?

I’m currently using Fetch to download the data, but from there unable to get it to write with the Filesystem plugin.

Using fetch should be enough for downloading files.

Can you expand on the issues you had with Filesystem plugin?

I think I’ve got it figured out now but went a completely different route, but happy to help explain our use case!

Basically we just wanted to provide users a way to download the files we reference in some of our pages. I’m way more familiar with android than iOS, so what I was expecting to find was something that triggered the notification in android showing that you’re downloading a file and expecting it to be easy to download to my Downloads folder. I saw the Downloader package, but assumed I needed an option that covered iOS and Android so I wrote that off.

The complications I ran into attempting to use fetch, axios, and capacitor-community/http was that I couldn’t find anything showing how to properly get blob data and write it to the file system. I was successful at getting it to show that it’s downloading data but then the file writer would say the data was empty. Then I was able with capacitor-community/http to get it to download the file but had no way to send it to the directory I was expecting to see the downloads in.

In the end I regrouped with my team and saw that it’s not really that common in iOS to trigger downloads the way I was thinking. So we ended up using the Download package and using Android Download Manager + the native sharing popup for iOS.

I think the solution we have is fine in the end but it did take a couple of days going in circles to find clear answers since Google brings up a lot of questions from 4-5 years ago with a mixture of saying “use the FileTransfer plugin” - “Don’t use file transfer it’s sunsetted” - “Still had to use file transfer after the sunsetting because fetch errors out with large files” - “File transfer has bugs because it hasn’t been touched in years”, etc.

I have run into the same issue. All the information for downloading large binary files reference using the FileTransfer plugin. For our purposes, we want to be able to download a zip file and unzip locally. The zip files average in the 50MB range but some contain videos and can be over 100MB. Our use case is for getting materials onto the device for offline use, like in the field where there may not be a connection at all.

If it helps I integrated this solution for blob

write_blob({
  path: 'Download/' + fileName,
  directory: Directory.Data,
  blob: BlobFile,
  recursive: true,
  on_fallback(errorDownload: any) {
    console.error('an error occured while downloading:');
    console.error(errorDownload);
  }
}).then(function(savedFile: string) {
  console.log('File saved to:', savedFile);
});

The only issue i still have is with Android 11 where i can’t save on an external folder (The downloads folder for example)