Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IONIC Error with Cordova file-transfer plugin

I am using the following version of IONIC and Cordova;

IONIC;

1.5.5

Cordova;

5.1.1

Build my mobile application. But when ever I finish building it and run it I keep getting the following exception:

Uncaught module cordova-plugin-file.ProgressEvent not found

Could someone please help me out ?.

like image 591
msrameshp Avatar asked Jul 06 '15 06:07

msrameshp


People also ask

What is Cordova plugin file transfer?

This plugin allows you to upload and download files. This plugin defines global FileTransfer , FileUploadOptions constructors. Although in the global scope, they are not available until after the deviceready event.

Is ionic still Cordova?

Difference between Ionic and Cordova. Ionic and Apache Cordova are not considered competitors; instead, Ionic is built on top of Cordova.


1 Answers

I had the same issue today and in my case this was because the version of the file-transfer plugin was not compatible with the File plugin I use.

The file transfer plugin requires the cordova-plugin-file.ProgressEvent (see FileTransfer.js in the file transfer plugin directory) But if you're still using an older version of the file plugin (in my case org.apache.cordova.file instead of cordova-plugin-file) then it can't resolve that.

So either you update your plugins so you use the cordova-file-plugin or you change the code of the FileTransfer plugin, this is not advised because when the plugins are reinstalled you will loose this change. But if for whatever reason you can't use the newer file plugin you can use this method.

On line 25 of the FileTransfer.js file change

ProgressEvent = require('cordova-plugin-file.ProgressEvent');

to

ProgressEvent = require('org.apache.cordova.file.ProgressEvent');

If that doesn't solve it, try to look up the correct module name in your File plugin directory's config.xml file (look for the ID property) and use that instead (don't forget to append ProgressEvent)

To elaborate on my point of not changing the code of the FileTransfer plugin you can however copy the plugin code and put it somewhere on your disk and use that plugin instead of the hosted one (which is loaded and used if you just use the plugin's ID)

like image 75
alwynW Avatar answered Oct 12 '22 14:10

alwynW