Roman Roman - 1 month ago 25
Android Question

Android annotations REST send image

I use android annotations to communicate with the server. In one of the api calls I need to send some text data and an image, say, from gallery.

@Post("/items/addItem.php")
String addItem(Protocol protocol);


How do I attach a MultipartForm with an image along with the post request?

Answer

Just use the right Spring converter : FormHttpMessageConverter.

However, this converter only accepts MultiValueMap as method parameter. Please have a look at these two issues: #652 and #660.

If you really want to use any object as parameter, you have to implement your own custom FormHttpMessageConverter which will handle that by using reflection.