So just ignore FileBody. You want to use the method MultipartEntity.addPart(ContentBody content). This works with FileBody, because FileBody's parent class implements ContentBody.
ContentBody is a super simple interface with just two methods. Create a class that implements it, create an instance of your class, and pass it in to the addPart method.
public ByteContentBody implements ContentBody {
private String name;
private byte[] data;
public ByteContentBody(String name, byte[] data) {
this.name = name;
this.data = data;
}
public String getFilename(){
returns name;
}
public void writeTo(OutputStream out) throws IOException {
out.write(data);
}
}