Consuming a multipart/form-data via RESTful CXF

拈花ヽ惹草 提交于 2019-11-30 19:16:24

I faced similar issue sometime back.

The following code did the trick for me

@POST
@Consumes("multipart/form-data")
public void yourMethod(<params>) throws Exception {
}

In short, it is I think the @Consumes annotation you are missing.

It seems we found the problem, and it was related to the format of the request. The correct format should have been:

Content-type: multipart/form-data, boundary=AaB03x

--AaB03x
content-disposition: form-data; name="mode"

T--AaB03x

content-disposition: form-data; name="type"

M--AaB03x

content-disposition: form-data; name="path"

c:/img/--AaB03x

content-disposition: form-data; name="image"; filename="image.jpg"
Content-Type: image/jpeg
Content-Transfer-Encoding: binary

imgdata--AaB03x--

Changing to this format allowed me to consume the other parameters.

For consuming multipart form data. use @consumes tag & provide "multipart/form-data" along with value parameter like

@Consumes(value = "multipart/form-data")

refer https://jnorthr.wordpress.com/2012/07/10/http-header-content-type-and-encodings/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!