尝试使用此REST调用上传文件,但找到空数组
**Spring**:
//Multi file upload
@RequestMapping(value = "/api/upload/multipart", method = RequestMethod.POST,consumes = { "multipart/form-data" } )
// If not @RestController, uncomment this
@ResponseBody
public ResponseEntity<?> uploadFile(
@RequestParam("file") MultipartFile[] uploadfileList, @RequestParam("fileType") String fileType) throws InvalidKeyException, BadPaddingException, IllegalBlockSizeException, IOException {
logger.debug("Multiple file upload!");
MultipartFile uploadfileimage;
List<FileUpload> fileuploadList = new ArrayList<>();
for (int i = 0; i < uploadfileList.length ; i++) {
uploadfileimage = uploadfileList[i];
FileUpload fileUpload = new FileUpload();
fileUpload.setFileName(uploadfileimage.getOriginalFilename());
fileUpload.setData(uploadfileimage.getBytes());
fileUpload.setFileType(fileType);
fileuploadList.add(fileUpload);
}
fileuploadList = (List<FileUpload>)
fileUploadRepository.saveAll(fileuploadList);
return new ResponseEntity("Successfully uploaded - " +
fileuploadList, new HttpHeaders(), HttpStatus.OK);
}
可能为空[]的原因是什么?任何帮助将不胜感激。