"Need to do multipart/form-data uploads?"
Created by: JulienLeal
The example of "Need to do multipart/form-data uploads? That works too." Doesn't work !!!
AsyncHttpPost post = new AsyncHttpPost("http://myservercom/postform.html");
MultipartFormDataBody body = new MultipartFormDataBody();
body.addFilePart("my-file", new File("/path/to/file.txt"));
body.addStringPart("foo", "bar");
post.setBody(body);
AsyncHttpClient.getDefaultInstance().execute(post, new StringCallback() {
@Override
public void onCompleted(Exception ex, AsyncHttpResponse source, String result) {
if (ex != null) {
ex.printStackTrace();
return;
}
System.out.println("Server says: " + result);
}
});
This have an error with "new StringCallback", because "argument mismatch; cannot be converted to HttpConnectCallback)". I don't know how I fix this. I search for that issue but I don't find :(.
Follow the complete error "Error:(50, 49) error: no suitable method found for execute(AsyncHttpPost,) method AsyncHttpClient.execute(AsyncHttpRequest,HttpConnectCallback) is not applicable (argument mismatch; cannot be converted to HttpConnectCallback) method AsyncHttpClient.execute(String,HttpConnectCallback) is not applicable (argument mismatch; AsyncHttpPost cannot be converted to String) method AsyncHttpClient.execute(AsyncHttpRequest,AsyncParser,RequestCallback) is not applicable (cannot infer type-variable(s) T (actual and formal argument lists differ in length)) where T is a type-variable: T extends Object declared in method execute(AsyncHttpRequest,AsyncParser,RequestCallback)"