feat: add `file-transfer` plugin
Is your feature request related to a problem? Please describe:
Currently there is no Capacitor 4 compatible plugin that can be used to upload and download files.
Describe the solution you'd like:
Create a plugin that allows you to upload and download files.
Describe alternatives you've considered:
Additional context:
Related to https://github.com/ionic-team/capacitor/issues/5964
@robingenz there is this plugin https://github.com/AlwaysLoveme/capacitor-plugin-filedownload not sure if can help or contribute to it.
Capacitor Filesystem will soon be able to download files and Http has been updated to handle FormData and files in FormData.
This plugin will offer advanced features. That is why it is still on the roadmap, at least for now.
Cool! Then I will add my "request" for an advanced-feature: progress event callback for each download instead/(additionally) of a listener on all request (like it is with the current implementation by Ionic-Team).
Our use-case is a download-widget which downloads >1800 files in parallel in batches and I would like to have a proper kb/s and estimated time progress in it. Our current implementation works but it requires to cache the url and loaded bytes in a Set and other hacky stuff to make it work.
My current implementation (Android is done, iOS & Web is pending) also uses a listener for all uploads/downloads, but instead of using url to identify a request, I currently use a unique requestId.
I may change this. There are of course more features to come. Be prepared and subscribe to the issue!
Feel free to let me know if you have more ideas.
Ah, great, that would work a little better if it is returned with each event.
Just sharing my listener here for anyone looking for that:
Http download listener
private createHttpListener() {
return Filesystem.addListener("progress", ({ url, bytes, contentLength }) => {
const progress = new DownloadProgress(
this.remaining,
this.bytesTotal,
this.bytesLoaded,
contentLength,
)
if (!url.includes("your-domain.")) {
// Files coming from other servers have no file size so we need to get that
// value during file download.
if (contentLength === 0) {
// Some servers do not respond with a content length.
this.event.downloadProgressChange.next(progress)
return
}
if (!this.previousBytes.has(url)) {
this.bytesTotal += contentLength
this.previousBytes.set(url, 0)
}
}
this.bytesLoaded += bytes - (this.previousBytes.get(url) || 0)
this.previousBytes.set(url, bytes)
this.event.downloadProgressChange.next(progress)
})
}
Are there any infos when or in which version Upload/Download will be available?
@SchneMa ETA is next month.
Any news on this?
Any news on this?
I prioritized the development of another plugin for a sponsor (see https://github.com/capawesome-team/capacitor-firebase/pull/434). Therefore, the development of this plugin has been postponed.
Any news?, I want to upload large files (videos) with capacitor without Ionic and I read "The File Handling Guide for Capacitor" and here mentions that there are plugins to upload files directly to server but I have no idea what they are
@lsolano2707 A few plugins are:
But this plugin is not yet available.