Hi,
I am facing an issue while I am trying to send a Multipart Entity with the http
client nio api. I received the UnsupportedOperationException exception.
I am using the following libraries: httpcore-nio-4.0.1; httpmime-4.0.1 and
apache-mime4j-0.6.
The multipart message is built with the following code sample:
BasicHttpEntityEnclosingRequest httppost = new
BasicHttpEntityEnclosingRequest( "POST", "http://localhost:8080 ");
// Get stream from file
FileInputStream fileStream = new FileInputStream( new File( args[0]));
InputStreamBody streamBody = new InputStreamBody( fileStream,
"image/png", args[0]);
// Add a string
StringBody comment = new StringBody( "A binary file of some kind",
Charset.forName("UTF-8"));
MultipartEntity reqEntity = new MultipartEntity();
reqEntity.addPart("comment", comment);
reqEntity.addPart("bin", streamBody);
httppost.setEntity( reqEntity);
The http request is sent using the http client nio api.
It seems that somewhere the multipart entity is encapsulated in a
NHttpEntityWrapper class that calls the getContent() method of the entity at
its construction.
The problem is that the MultipartEntity throws the
UnsupportedOperationException and no code is provided at the moment for this
method.
Can you tell me if it is planned to support this functionality in the future ?
Do you known any kind of workaround to solve this problem ?
Thank you for your help.
Franck.