Reputation: 897
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}
Upvotes: 5
Views: 6390
Reputation: 897
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!
Upvotes: 19