I’m trying to take a pic and save it on local storage, but i don't know too much about base64 (it’s the type which one retrieves the camera) and i miss some easy way. But the problem is there’s no new way to do it easier, anyone knows some way actually? Thank you so much

I’m following these tutorials, but it doesn't convince me, as you can see there are too many beta versions and don’t know what to use “ionic-native”, “capacitor” or “cordova”? too much information and no-updated…



My Code:

startCamera() {

    const options: CameraOptions = {
        quality: 100,
        destinationType: this.camera.DestinationType.FILE_URI,
        encodingType: this.camera.EncodingType.JPEG,
        mediaType: this.camera.MediaType.PICTURE

    this.camera.getPicture(options).then(imageData => {
        // imageData is either a base64 encoded string or a file URI
        // If it's base64 (DATA_URL):
        //let base64Image = 'data:image/jpeg;base64,' + imageData;
        var currentName = imageData.substring(imageData.lastIndexOf('/') + 1);
        var correctPath = imageData.substring(0, imageData.lastIndexOf('/'))
    }, (err) => {
        this.user.presentAlert("Error", err)

createFilename() {
    var d = new Date(),
        n = d.getTime(),
        newFilename = n + ".jpg";
    return newFilename;

1 Answers

M. Mariscal On Best Solutions


Adding this on CameraOptions:

saveToPhotoAlbum: true