如何解决IBM MobileFirst Adapter接受Multipart请求
我是IBM MobileFirst的新手,我正在尝试使用Multipart上传图像。每当我尝试调用API上传图像时,邮递员都会收到错误消息,提示找不到415内容或500服务器错误。所以我只想知道IBM Mobile First Java适配器是否接受多部分请求?
我已经附上了所使用的Java代码,但是这些都没有用:
1)
@RequestMapping(value = "/uploadFile",method = RequestMethod.POST)
public @ResponseBody
String uploadFileHandler(@RequestParam("file") MultipartFile file)
{
return null;
}
-
也尝试过此操作:
@POST @Path("/upload") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @OAuthSecurity(enabled=false) public ResponseEntity<?> upload(@RequestParam("files") MultipartFile files) { log.info("XXXXXXXXXXXXXXXXXXXX"); return null;
}
-
@POST @Path("/addEmployeeAttachment") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.MULTIPART_FORM_DATA) @OAuthSecurity(enabled=false) public @ResponseBody Map<String,Object> addEmployeeAttachment( @RequestParam(required = false,value = "attachmentFile") MultipartFile attachmentFile) { log.info("xxxxxxxxxx"); return null; }
解决方法
参考IBM Mobile首次开发参考文档https://www.ibm.com/support/knowledgecenter/SSHS8R_8.0.0/com.ibm.worklight.apiref.doc/apiref/c_restapi_oview.html
我们可以使用Deploy (POST)
来部署多部分压缩文件。
JSON示例:-
{
"ok" : false,"productVersion" : "8.0","transaction" : {
"appServerId" : "Tomcat","description" : {
"name" : "myname","type" : "mytype",},"errors" : [
{
"details" : "An internal error occured.",...
],"id" : 1,"project" : {
"name" : "myproject","status" : "FAILURE","timeCreated" : "2014-04-13T00:18:36.979Z","timeUpdated" : "2014-04-14T00:18:36.979Z","type" : "UPLOAD_ARTIFACT","userName" : "demouser",}
标准错误代码:-
Errors 400 No deployable data is provided. 403 The user is not
authorized to call this service. 404 The corresponding runtime is not
found or not running. 500 An internal error occurred.
您是否也可以引用How can I make a multipart/form-data POST request using Java?。
我希望它能帮助您了解有关multipart API的更多信息。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。