Since the code below has deprecated classes I've tried all day to find .jars to import that have Apache HttpClient MultipartEntityBuilder class that will import and compile. Below is the old code given to me by the API developer, but it has deprecated classes.
// Image + Multipart
File image = new File(imageFilename);
ContentBody body =
new FileBody(image, "image/jpeg", "image_file", null);
MultipartEntity multipartContent = new MultipartEntity();
multipartContent.addPart("image_file", body);
Here is what I've been trying:
// Image + Multipart
File image = new File(imageFilename);
ContentBody body =
new FileBody(image, "image/jpeg", "image_file", null);
MultipartEntityBuilder multipartContent = new MultipartEntityBuilder();
multipartContent.addPart("image_file", body);
build.gradle looks like this:
dependencies {
compile files('libs/moodstocks.jar')
compile files('org.apache.commons.httpclient.jar')
compile files('libs/httpcore-4.0.1.jar')
compile files('libs/httpcore-4.0.1-sources.jar')
compile files('libs/httpclient-4.0.1-sources.jar')
compile files('libs/httpclient-4.3.5.jar')
compile files('libs/httpmime-4.3.6.jar')
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
}
You can see that I've put a lot of .jars in my libs folder trying to find something that would play nice. I'm essentially just trying to send an image file with a string to an API using Digest Authentication.
I've struggled with this at various times for quite awhile and now that I have most other pieces working I need to figure this communication out.
I ended up not needing MultiPartEntityBuilder -- could do with MultiPartEntity. thanks