I am in need to implement a feature in my Ionic2
app where users can download a specific Video file into Ionic2 app.
Upon checking the Ionic Native
section, I found that the following plugins available :
But could not find anything such as 'cordova-plugin-file-transfer' where a specific method exists as DOWNLOAD.
What could be the way out ?
Please suggest.
You should use "Transfer" plugin for downloading a file in ionic2
You can install plugin by this command
ionic plugin add cordova-plugin-file-transfer
npm install --save @ionic-native/transfer
and then import it
import { Transfer, FileUploadOptions, TransferObject } from '@ionic-native/transfer';
set constructor
constructor(private transfer: Transfer, private file: File) { }
Then use this function to download file using url
download() {
const url = 'http://www.example.com/file.pdf';
fileTransfer.download(url, this.file.dataDirectory +
'file.pdf').then((entry) => {
console.log('download complete: ' + entry.toURL());
}, (error) => {
// handle error
});
}
Hope it help you You can also upload a file using this Plugin
You can use Transfer native plugin for that.
This plugin allows you to upload and download files.
Git Repo.
ionic plugin add cordova-plugin-file-transfer
npm install --save @ionic-native/transfer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With