title: Insert Image to database using typescript (angular2) and spring boot (spring data)
body: <p>I start by presenting my client side the service </p>
  
  <pre><code>    addImage (url: string, params: string[], files: File[]): Observable {
                  return Observable.create(observer =&gt; {
                      let formData: FormData = new FormData(),
                          xhr: XMLHttpRequest = new XMLHttpRequest();
  
                      for (let i = 0; i &lt; files.length; i++) {
                          formData.append("uploads[]", files[i], file
  
  s[i].name);
                  }
  
                  xhr.onreadystatechange = () =&gt; {
                      if (xhr.readyState === 4) {
                          if (xhr.status === 200) {
                              observer.next(JSON.parse(xhr.response));
                              observer.complete();
                          } else {
                              observer.error(xhr.response);
                          }
                      }
                  };
  
                  xhr.upload.onprogress = (event) =&gt; {
                      this.progress = Math.round(event.loaded / event.total * 100);
  
                      this.progressObserver.next(this.progress);
                  };
  
                  xhr.open('POST', url, true);
                  xhr.send(formData);
              });
  
      }
  </code></pre>
  
  <p>then this is my html code </p>
  
  <pre><code>&lt;input type="file" (change)="uploadImage($event)"/&gt;
  </code></pre>
  
  <p>where I call this method from my component </p>
  
  <pre><code>uploadImage(event) {
          var files = event.srcElement.files;
          console.log(files);
          this._serviceSection.addImage('http://localhost:8080/template/img', [], files).subscribe(() =&gt; {
              console.log('sent');
          });
      }
  </code></pre>
  
  <p>and in my service side </p>
  
  <p>this is a method from my controller </p>
  
  <pre><code>@RequestMapping(value = "/img", method = RequestMethod.POST)
      public void getFileContents(@RequestParam MultipartFile file) {
          System.out.println("++++++++++++++++++++++++++++++++++++++++ " +file.getOriginalFilename());
      }
  </code></pre>
  
  <p>in a first time a try just to show a fileName but I get this error</p>
  
  <p><a href="https://i.stack.imgur.com/Q36Gf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Q36Gf.png" alt="enter image description here"></a></p>