Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't resolve all parameters for File

I am trying to implement https://ionicframework.com/docs/native/file-transfer/

Therefor I need to install https://ionicframework.com/docs/native/file/

When I use "File" in my service I get the error:

Can't resolve all parameters for File: (?, ?, ?, ?, ?).

I know that the question marks can resemble a circular reference tough I've never user my service anywhere else, nor did i use "File" before.

import {Injectable} from '@angular/core';
import {File} from "@ionic-native/file";
import { FileTransfer, FileTransferObject } from '@ionic-native/file-transfer';

@Injectable()
export class ImageService {

  constructor(private file: File, private transfer: FileTransfer) {

  }

  public getImagesOfSchedule() {
    const fileTransfer: FileTransferObject = this.transfer.create();
    const url = 'http://techbooster.be/wp-content/uploads/2017/11/logo-long-white.png';
    fileTransfer.download(url, this.file.dataDirectory + 'file.pdf').then((entry) => {
      console.log('download complete: ' + entry.toURL());
    }, (error) => {
      // handle error
    });
  }

}

app.module.ts

providers: [
    StatusBar,
    AuthenticationService,
    ScheduleService,
    ToastService,
    StorageService,
    FacebookService,
    GoogleService,
    ImageService,
    Facebook,
    GooglePlus,
    PushService,
    File, <----------------
    FileTransfer, <--------------
    Push,
    ScreenOrientation,
    {
      provide: HttpService,
      useFactory: HttpFactory,
      deps: [XHRBackend, RequestOptions]
    },
    {
      provide: HttpNoAuthService,
      useFactory: HttpFactory,
      deps: [XHRBackend, RequestOptions]
    },
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
like image 847
Sytham Avatar asked Dec 02 '22 12:12

Sytham


1 Answers

Ok I found out that the File class automatically imported in app.module.ts was not:

import { File } from '@ionic-native/file';

Instead it was some standard "lib.es6.d.ts" automatically imported.

So make sure you import the correct "File" class!

like image 53
Sytham Avatar answered Dec 31 '22 07:12

Sytham