I'm able to upload Images successfully by ion-input but not able to upload image by camera in ionic angular

hello everyone , I’m successfully click image by camera but not able to send camera response on server by API.

this is my code :point_down:

click picture code

this is file reader code

and this is my upload image code

please help me as soon as possible…:pray:
thank you :blush:

I don’t take pictures directly via camera (yet), but i upload files via input type=“file”. Maybe my methods/functions can help you.

This is my change event that uploads the img:

onSelectFile(event) {
    if (event.target.files && event.target.files[0]) {
      const reader = new FileReader();
      reader.readAsDataURL(event.target.files[0]); // read file as data url
      reader.onload = (event) => {
        // called once readAsDataURL is completed
        this.imageDataURL = event.target.result as string;
        this.attachmentService.base64$.next(this.imageDataURL);
        this.openModal();
      };
    }
  }

As you can see in the following code-block, I had to cut off the first part of the base64-code of the images:

base64: data:image/png;base64,`

send() {
    this.loadingService.loading.next(true);
    const currentAudit = this.attachmentService.audit;
    let newAttachment: Attachment;
    let file_name = '';

    file_name +=
      this.attachmentService.audit.form.match_code +
      this.createAttachmentNameDate();
    let file_content = '';
// This could be interesting for you vin001
    if (this.base64.indexOf('base64') > -1) {
      file_content = this.base64.split('base64,')[1];
    } else {
      file_content = this.base64;
    }
    if (this.isSignature) {
      file_name += '_u';
    }

    this.attachmentService.postAttachment(file_name, file_content).subscribe({
      next: (response) => {
        console.log('postAttachment: response: ', response);
        newAttachment = response;
      },
      error: (error) => {
        console.log('postAttachment: ', error);
      },
      complete: () => {
        this.attachmentService
          .addAttachmentToAudit(currentAudit, newAttachment.id)
          .subscribe({
            next: (response2) => {
              console.log('addAttachmentToAudit: resonse: ', response2);
            },
            error: (error) => {
              console.log('postAttachment: error: ', error);
            },
            complete: () => {
              this.attachmentService.attachments$.next(
                this.attachmentService.getAllAttachments(currentAudit)
              );
              this.discard();
              this.loadingService.loading.next(false);
            },
          });
      },
    });
  }