Question

I try to send multiple Files from my Server (NanoHttpd) to my Client (Apache DefaultHttpClient). My approach is to send multiple files via one Response of NanoHttpd.
I can only send one InputStream in the Response and as far as i know i could only use one Response for a Request.

I have tried this with SequenceInputStream, but this merges all files together.
Is there any way to send multiple files in one InputStream without merging them, so i could access them with my individually ?

Thanks in advance.

Was it helpful?

Solution

You can use MIME/Multipart encoding in your response, which is a standard way of sending multipart, structured content over HTTP, and that the Apache client should be able to decode on the fly (although on the server side, you should use a library to produce this not so trivial encoding).

Another way, probably easier, could be to send a ZIP stream on the server side : the JDK has everything to both encode and decode the data on both sides, see ZipEntry and ZipInputStream/ZipOutputstream.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top