I am currently utilizing Ionic with Angular to develop an application. Within my app, I incorporate CouchDB for downloading images.
My device of choice is an Android Phone.
During my attempt to download a file using the file opener, I encountered the following error message:
(Status:9 message:file not found)
<ion-item mode=md class="input-group ion-no-padding viewFile" lines=none *ngIf="common.isDocumentFill">
<span (click)="doc(fc)">View File</span>
</ion-item>
//function
doc(objFC) {
let obj = {
ServiceId: 1,
CouchDBDocId: objFC.CouchDBDocId,
DocumentName: objFC.FileName
}
this.api.getPdf(obj).subscribe((data: any) => {
// debugger
let blob = new Blob([data], { type: data.type });
var downloadURL = window.URL.createObjectURL(data);
var types = data.type
this.down(downloadURL, types)
});
}
down(filepath, mimeType) {
this.fileOpener.open(filepath, mimeType)
.then(() =>
console.log('File is opened')
)
.catch(e => console.log('Error opening file', e));
}
and Service
getPdf(obj) {
// debugger
const httpOptions = {
responseType: 'blob' as 'json'
};
return this.http.post(this.url + "DocumentDetails/DownloadFile", obj, httpOptions);
}