kendo-upload REST API receiving NULL for Image

1 Answer 115 Views
Upload
chethanagaajula
Top achievements
Rank 1
Iron
chethanagaajula asked on 29 Apr 2022, 08:05 AM

I'm using Kendo-Upload in Angular:

<div class="flex flex-col max-w-375">
    <kendo-uploaddropzone zoneId="uploadImagesZone">
      Only JPEG and PNG files are allowed.
    </kendo-uploaddropzone>
    <kendo-upload zoneId="uploadImagesZone" [autoUpload]="false"
      [saveUrl]="this.uploadImagesURL" [removeUrl]="this.removeImageUrl"
      (remove)="onRemove($event)" (cancel)="onCancel($event)"
      (success)="onUpload($event)" [restrictions]="myRestrictions"
                  [multiple]="true"
      [showFileList]="true" responseType="text">
    </kendo-upload>
  </div>

I've validated that the value of "this.uploadImagesURL" is set correctly and clicking on UPLOAD hits the right endpoint (Java Spring REST API):

@PostMapping("image/{name}")
public ResponseEntity<ImageDetails> compressImage(@RequestBody MultipartFile image, @PathVariable final String name) {
}
However, the value of image is NULL.

I've tested this endpoint via Postman and verified that "image" does contain the image. Why does the value set to NULL when the endpoint is called via Kendo-Upload

1 Answer, 1 is accepted

Sort by
0
Accepted
chethanagaajula
Top achievements
Rank 1
Iron
answered on 29 Apr 2022, 05:14 PM

Got this resolved after I observed some specific information in the documentation: https://www.telerik.com/kendo-angular-ui/components/uploads/api/UploadComponent/#toc-savefield

New endpoint:

@RequestMapping(path = "image/{name}", method = POST, consumes = {MediaType.MULTIPART_FORM_DATA_VALUE}) public ResponseEntity<ImageDetails> compressImage(@RequestPart("files") MultipartFile imageFile, @PathVariable final name) {

}


Tags
Upload
Asked by
chethanagaajula
Top achievements
Rank 1
Iron
Answers by
chethanagaajula
Top achievements
Rank 1
Iron
Share this question
or