0

I want to add an encripted stream to my multipartentity to upload it to my servlet but I don't know how to do that... Emm then MultipartEntity is quite limited as for addPart(...,...) method params. I found no examples in that area so I need your help. Please share any useful snippets and ideas.

Any comment is appreciated.

Andrew

P.S. I am using HttpClient 4

Marek Sebera
  • 39,650
  • 37
  • 158
  • 244
user592704
  • 3,674
  • 11
  • 70
  • 107

1 Answers1

2

Have you tried to encapsulate the CipherInputStream into a org.apache.http.entity.mime.content.InputStreamBody?

Afterwards you can encapsulate it in an org.apache.http.entity.mime.FormBodyPart which can be added via addBodyPart() to your HttpMultipart instance.

Robert
  • 39,162
  • 17
  • 99
  • 152
  • No I haven't tried to encapsulate because I suppose to upload big files which demand buffer reading no to have the outOfMemory error... – user592704 Mar 21 '11 at 01:37
  • The problem is that the addPart() demands FileInputStream as a param but the CipherInputStream encrypted result is FileOutputStream :( – user592704 Mar 21 '11 at 01:39
  • Moreover, if file is big it takes too much time to "encrypt" then "upload" :( Both demand time so I guess there should be a way around? – user592704 Mar 21 '11 at 01:40
  • Please read exactly what I have read. I was taking about the method `addBodyPart()` not `addPart()` - therefore I assume we are talking about different classes. This happened because you did not include the code you are using. – Robert Mar 21 '11 at 18:19