Currently, I am in the process of developing an application utilizing ionic 3. The main functionality of the app involves capturing an image from an external camera (which will return a file URL) and then saving it in a local database using sqllite as base64.
Below is my implementation:
takeImage(){
const fileTransfer: FileTransferObject = this.transfer.create();
this.takePicture().subscribe(data => {
this.wait(7000);
this.listFiles().subscribe(data => {
const url = data['results'].entries[0].fileUrl;
fileTransfer.download(url, this.file.dataDirectory + data['results'].entries[0].name).then((entry) => {
this.room.img = entry.toURL();
this.base64.encodeFile( entry.toURL()).then((base64File: string) => {
this.room.img = base64File;},
(err) => {
console.log(err);
});
}, (error) => {});
},
err => {console.log(err);});
},
err => {console.log(err);});
}
Despite my best efforts, I have encountered difficulties in displaying the base64File
.