title: SyntaxError: Unexpected token D at Object.parse (native)
body: <p>I am uploading files using Spring Boot and Angular JS. My Java controller returns some details of a file such as the date, the type, the inputs of the form which are the name of the uploader and the file.</p>
  
  <p>So when I click on <code>import Report</code>, I can upload the file, but I don't have the details added to the table. I have an empty row.</p>
  
  <p>So what am  doing wrong?</p>
  
  <p>Here's my form:</p>
  
  <pre class="lang-html prettyprint-override"><code> &lt;section id="contact-info"&gt;
  
      &lt;section id="contact-page"&gt;
          &lt;div class="container"&gt;
              &lt;div class="center"&gt;
                  &lt;p class="lead"&gt;Import reports&lt;/p&gt;
              &lt;/div&gt; 
              &lt;div class="row contact-wrap"&gt; 
                  &lt;div class="status alert alert-success" style="display: none"&gt;&lt;/div&gt;
                  &lt;form id="main-contact-form" class="contact-form" name="contact-form" method="POST" enctype="multipart/form-data" &gt;
                      &lt;div class="col-sm-5 col-sm-offset-1"&gt;
                          &lt;div class="form-group"&gt;
                              &lt;label&gt;name *&lt;/label&gt;
                              &lt;input type="text" name="NameOfUploader" class="form-control" required="required" ng-model="r.NameOfUploader"&gt;
                          &lt;/div&gt;
  
                          &lt;div class="form-group"&gt;
                              &lt;label&gt;file&lt;/label&gt;
                              &lt;input type="file" name="file" class="form-control" fileread="r.file"&gt;
                          &lt;/div&gt;   
  </code></pre>
  
  <p>My controller java</p>
  
  <pre class="lang-java prettyprint-override"><code>public class DRController {
      @Autowired
      private DetailsReportRepository detailsReportRepository;
      @RequestMapping(value="/upload",headers=("content-type=multipart/*"),consumes = {"multipart/form-data"}, method=RequestMethod.POST)
      public @ResponseBody String  handleFileUpload(@RequestParam("NameOfUploader") String NameOfUploader,@RequestParam("file") MultipartFile file){
          if (!file.isEmpty()) {
              try {
  
                  DetailsReport d2=new DetailsReport();
                  d2.setNameOfUploader(NameOfUploader);
                  d2.setTypeOfFile(file.getContentType());
                  d2.setDateOfUpload(new Date(new java.util.Date().getTime()));
                  d2.setFile(convert(file));
                  detailsReportRepository.save(d2);
                  byte[] bytes = file.getBytes();
                  BufferedOutputStream stream =
                          new BufferedOutputStream(new FileOutputStream(new  File("F:/FilesStore/" + d2.getId_file()+"-"+d2.getNameOfUploader())));
                  stream.write(bytes);
                  stream.close();
                  return d2.toString();
             } catch (Exception e) {
                 System.err.print("erreur");
             }
          }
  
          return null;
      }
  
      public File convert(MultipartFile file)
      {    
          File convFile = new File(file.getOriginalFilename());
          try {
              convFile.createNewFile();
              FileOutputStream fos = new FileOutputStream(convFile); 
              fos.write(file.getBytes());
              fos.close();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          return convFile; 
      }
  }
  </code></pre>
  
  <p>My controller js </p>
  
  <pre class="lang-js prettyprint-override"><code>//Upload files
  $scope.upload = function() {
      var fd = new FormData();
      var url='http://localhost:8080/upload';
      fd.append("file", $scope.r.file);
      fd.append("NameOfUploader",$scope.r.NameOfUploader);
      $http.post(url,fd,{
          transformRequest: angular.identity,
          headers: {'Content-Type': undefined}
      })
      .success(function(data){
          var b=JSON.parse(data);
          $scope.reports.push(b); 
  
          console.log(Json.parse(data));
  
          console.log($scope.reports);
      })
      .error(function(){
      });
  }
  
  
  
  &lt;div class="form-group"&gt;
      &lt;a  class="btn btn-primary btn-lg"  ng-click="upload()"&gt;Import File&lt;/a&gt;
  &lt;/div&gt;
  &lt;table class="table"&gt;
      &lt;tr&gt;
          &lt;th&gt;Id_file&lt;/th&gt;
          &lt;th&gt;NameOfUploader&lt;/th&gt;
          &lt;th&gt;DateOfUpload&lt;/th&gt;
          &lt;th&gt;TypeOfFile&lt;/th&gt;
          &lt;th&gt;File&lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr ng-repeat="r in reports"&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;{{r.NameOfUploader}}&lt;/td&gt;
          &lt;td&gt;{{r.DateOfUpload}}&lt;/td&gt;
          &lt;td&gt;{{r.TypeOfFile}}&lt;/td&gt;
          &lt;td&gt;{{r.file}}&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;   
  &lt;/div&gt; 
  </code></pre>
  
  <p>Here's what I have:</p>
  
  <p><img src="https://i.stack.imgur.com/LNp0q.png" alt="enter image description here"></p>