这对我来说是一个非常戏剧性的情况,我不知道为休息客户提供有效负载是什么错误,因为我得到" 400:BAD REQUEST" 例外。下面是代码,请帮我解决一下,
@RequestMapping(value = "/uploadQuestionImg", method = RequestMethod.POST)
public ResponseEntity<FileMetadata> commonFileUpload(@RequestParam("file") MultipartFile file) {
FileMetadata fileInfo = null;
HttpStatus statusCode = HttpStatus.BAD_REQUEST;
if (!file.isEmpty()) {
try {
FileInfoService reqFile = createFileInfo(file, "");
fileInfo = (FileMetadata) operations.store(file.getInputStream(), reqFile);
statusCode = HttpStatus.OK;
} catch (Exception e) {
logger.warn("Exception occured", e);
statusCode = HttpStatus.INTERNAL_SERVER_ERROR;
}
} else {
logger.warn("Invalid request");
}
return new ResponseEntity<FileMetadata>(fileInfo, statusCode);
}
这是我传递给其余客户端的有效负载,
答案 0 :(得分:1)
kIOPMAssertionTypePreventUserIdleSystemSleep
错误。在您的情况下,您尝试发布请求,即400: BAD REQUEST
。请求应采用格式Multi part file upload request
其他服务器将抛出multi part file request
您可以尝试http://www.codejava.net/java-se/networking/upload-files-by-sending-multipart-request-programmatically使用此代码测试400: BAD REQUEST
。