Hey all! I am trying for two days now, to upload a file to my server. Here is my config:
Ionic: CLI 4.7.1
Cordova: 8.1.2 (cordova-lib@8.1.1)
I have added the following:
ionic cordova plugin add cordova-plugin-file-transfer
npm install @ionic-native/file-transfer
Afterwards I did put it within the app.module.ts like this:
import { FileTransfer} from '@ionic-native/file-transfer';
[... shorten ...]
providers: [
....
File,
FileTransfer,
Base64,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
and within my page I added the following:
import { FileTransfer, FileUploadOptions, FileTransferObject } from '@ionic-native/file-transfer';
constructor(public navCtrl: NavController, [..], private base64: Base64, public http: HttpClient, private transfer: FileTransfer) {
}
I even did not implement code but when I try to run:
ionic Cordova build iOS
I do get the following error:
[18:55:27] typescript: src/app/app.module.ts, line: 24
Argument of type '{ declarations: (typeof AboutPage | typeof ContactPage | typeof HomePage | typeof TabsPage
| type...' is not assignable to parameter of type 'NgModule'. Types of property 'providers' are
incompatible. Type '(typeof SplashScreen | typeof Camera | typeof Media | typeof File | typeof Base64 |
FileTransferO...' is not assignable to type 'Provider[]'. Type 'typeof SplashScreen | typeof Camera | typeof
Media | typeof File | typeof Base64 | FileTransferOr...' is not assignable to type 'Provider'. Type
'FileTransferOriginal' is not assignable to type 'Provider'. Type 'FileTransferOriginal' is not assignable
to type 'ClassProvider'. Property 'provide' is missing in type 'FileTransferOriginal'.
L24: @NgModule({
L25: declarations: [
[ ,,, ]
[18:55:27] ionic-app-script task: "build"
[18:55:27] Error: Failed to transpile program
Error: Failed to transpile program
at new BuildError (/Users/marie/playground/ionic/AppDevelopment/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28)
at /Users/marie/playground/ionic/AppDevelopment/node_modules/@ionic/app-scripts/dist/transpile.js:159:20
at new Promise (<anonymous>)
at transpileWorker (/Users/marie/playground/ionic/AppDevelopment/node_modules/@ionic/app-scripts/dist/transpile.js:107:12)
at Object.transpile (/Users/marie/playground/ionic/AppDevelopment/node_modules/@ionic/app-scripts/dist/transpile.js:64:12)
at /Users/marie/playground/ionic/AppDevelopment/node_modules/@ionic/app-scripts/dist/build.js:109:82
[ERROR] An error occurred while running subprocess ionic-app-scripts.
This error seems to be common but no-one did post a solution yet. Most of the references I found on Stackoverflow say - it is due to a deprecated plugin? Is this FileTransfer Plugin deprecated?
https://stackoverflow.com/questions/46068697/ionic-fileuploadoptions-throw-error-when-add-to-app-module-ts (This did not work for me)
Thanks