Hello
Emulating my app for android and trying to store a pdf file with the cordova-file-plugin I get the error message:
core.js:1449 ERROR TypeError: Object(…) is not a function
at File.get [as dataDirectory] (index.js:649)
at MergeMapSubscriber.project (euro-bus-test.ts:83)
The code:
import {File} from '@ionic-native/file/ngx';
constructor( public navCtrl: NavController,
public navParams: NavParams,
public http: HttpClient,
private storage :Storage,
private file: File) {
}
private downloadFile(url:string, fileName : string): Observable<any> {
return this.http.get(url, {responseType: 'blob'})
.flatMap((data: Blob) => {
return Observable.from(this.file.writeFile(this.file.dataDirectory, fileName, data, {replace: true}))
})
}
The error happens in this line of code:
this.file.writeFile(this.file.dataDirectory, fileName, data, {replace: true})
When I check the dataDirectory in the debugger it says:
ioinic-nativ file plugin ReferenceError: documentsDirectory is not defined
When I check this.file.dataDirectory it says: TypeError: Object(…) is not a function
The other point is, that the import only ‘works’, if I import from ‘file/ngx’ like in shown in the code. Without /ngx the imported ‘File’ is not used in the constructor, and the method writeFile() doesn’t exists (of course).This wasn’t nessecary yesterday.