FileTransfer plugin, editing a form with an image issues

i have this scenario:

  1. A user uploads a form with an image
  2. Later the user decides to edit the form, but he doesn’t change the image, only some form fields.

Here’s the code:

actionHandler(selection: any) {
    var options: CameraOptions;

    if (selection == 1) {
      options = {
        quality         : 75,
        destinationType : Camera.DestinationType.FILE_URI,
        sourceType      : Camera.PictureSourceType.PHOTOLIBRARY,
        allowEdit       : false,
        encodingType    : Camera.EncodingType.JPEG,
        targetWidth     : 500,
        targetHeight    : 500,
        saveToPhotoAlbum: false,
        mediaType       : Camera.MediaType.PICTURE,
      };
    } else {
      options = {
        quality           : 75,
        destinationType   : Camera.DestinationType.FILE_URI,
        sourceType        : Camera.PictureSourceType.CAMERA,
        allowEdit         : false,
        encodingType      : Camera.EncodingType.JPEG,
        targetWidth       : 500,
        targetHeight      : 500,
        saveToPhotoAlbum  : false,
        correctOrientation: true
      };
    }

    Camera.getPicture(options).then((file_uri) => {
        if (this.platform.is('android') && selection === 1) {
          this.isAndroid = true;
          FilePath.resolveNativePath(file_uri)
            .then(filePath => {
              var fileName      = file_uri.substr(file_uri.lastIndexOf('/') + 1);
              fileName          = fileName.substr(0, fileName.lastIndexOf('?'));
              var filePath      = filePath.substr(0, file_uri.lastIndexOf('/') + 1);
              var fileExtension = file_uri.substr(file_uri.lastIndexOf('.'));
              this.copyFileToLocalDir(fileName, filePath, this.createFileName(fileExtension));
              this.imageChosen = 1;
            });
        }
        else {
          this.isios       = true;
          this.lastImage   = file_uri;
          this.imageChosen = 1;
        }
      },
      err => {
        const alert = this.alertCtrl.create({
          title  : 'Problem adding image',
          message: '',
          buttons: ['OΚ']
        });
        alert.present();
      });
  }

  private copyFileToLocalDir(fileName, filePath, newFileName) {
    File.copyFile(filePath, fileName, cordova.file.dataDirectory, newFileName).then(success => {
      this.lastImage = newFileName;
    }, error => {
      this.presentToast(There was a problem');
    });
  }

  private createFileName(fileExtension) {
    var date        = new Date(),
        time        = date.getTime(),
        newFileName = time + '.jpg';
    return newFileName;
  }

  public pathForImage(lastImage) {
    if (lastImage === null) {
      return '';
    }
    else
      return cordova.file.dataDirectory + lastImage;
  }

An here is the upload logic when the user submits the form:

uploadImage() {
    let coords = this.longitude + ',' + this.latitude;
    this.storage.get('id_token').then((token) => {
      this.token = token;
    });
    let url = 'http://192.168.1.103:3000/api/user/edit';
   
    let ft  = new Transfer();

    if (this.platform.is('android')) {
      var targetPath = this.pathForImage(this.lastImage);
    } else {
      targetPath = this.lastImage;
    }
     this.filename = this.lastImage;

    let options  = {
      headers    : {'Authorization': 'JWT ' + this.token},
      fileKey    : 'fileUp',
      fileName   : this.filename,
      chunkedMode: false,
      httpMethod : 'PUT',
      params     : {
        name            : this.addForm.value.name,
        petType         : this.addForm.value.petType,
        lost            : this.lost,
        lostCoords      : coords
      }
    };
    this.loading = this.loadingCtrl.create({
      content: 'Saving...',
    });
    this.loading.present();
    ft.upload(targetPath, encodeURI(url), options)
      .then((result: any) => {
        this.imageChosen = 0;
        this.imagePath   = '';
        this.loading.dismissAll();
        this.presentToast('The form submitted successfully');
        this.loading.dismiss();
        this.navCtrl.setRoot(HomePage, {animate: true, direction: 'back'});
      }).catch((error: any) => {
      this.presentAlert('Problem editing the form','', ['OK'])
      this.loading.dismiss();
    });
  }

When user saves the form, android studio fires the java.io.FileNotFoundException: /data/user/0/com.ionicframework.myapp644228/files: open failed: EISDIR (Is a directory) error.

How i can upload the form without “touching” the file upload part and avoid storing an empty string in the database in the imageURL schema in mongodb?

Sorry, how exactly does your app work?

Use can enter some data and select an image. He clicks “Save” and then… it gets transfered to a backend API?
Later the user wants to edit some of the data he entered, but not the image?

user submits a form with an image, the form data is saved to an API (image and input boxes).

User decides later on to edit the form, but only the inputs, he leaves the image intact.

Ok, then just present the user with a form that displays only the input fields but not the image. On “Save” on this form use another backend endpoint (or adapt the old one) to only change input, not the image.