I am sending a multipart request to a server which will include an image, as well as a couple of strings. I haven't found any guide on how to get this done, all i have found are just how to make post and get and put etc, but nothing on multipart. I would be glad for any help, thanks
Here you have a example to do declare it using a @Rest interface and here you have a example to do it using Spring Android (used by AA to generate the client class)
All together you can use something like this (this code is not tested):
@Rest(rootUrl = "http://mycompany.com/images", converters = FormHttpMessageConverter.class)
public interface RestClient {
@Post("/loadimage")
void sendImage(MultiValueMap formfields);
}
@EActivity
public class MyActivity extends Activity {
@RestService
RestClient restClient; //Inject it
void sendImage(InputStream in) {
MultiValueMap values = new org.springframework.util.LinkedMultiValueMap<String,Object>();
try {
values.put("fileName", "a.jpg");
values.put("file", in);
restClient.sendImage(values);
} finally {
in.close();
}
}
}