ERROR TypeError: Failed to execute 'append' on 'FormData': parameter 2 is not of type 'Blob'. Angular 6 ERROR TypeError: Failed to execute 'append' on 'FormData': parameter 2 is not of type 'Blob'. Angular 6 express express

ERROR TypeError: Failed to execute 'append' on 'FormData': parameter 2 is not of type 'Blob'. Angular 6


The issue appears to be that the uploaded file was not converted to a Blob.

 onImagePicked(event: Event) {    const file = (event.target as HTMLInputElement).files[0];    this.form.patchValue({ image: file });    this.form.get('image').updateValueAndValidity();    const reader = new FileReader();    reader.onload = function(e) {      this.imagePreview = <string>reader.result;      // convert uploaded file to blob      const blob = new Blob([new Uint8Array(e.target.result)], {type: file.type });    };  }

Source: Convert data file to blob


Perhaps completely unrelated to your question, but in case it may be helpful to someone else, I got the same issue using React when trying to upload multiple files using ant design. My issue was that I was using this:

const formData = new FormData()formData.append(    "file",    file[0],    file[0].name);

Which has file[0] as an object

Instead of this:

const formData = new FormData()formData.append(    "file",     file[0].originFileObj,     file[0].originFileObj.name);

Which gives me a file.