MultipartOutputStream
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Daron_Finn
Posted On:   Wednesday, December 19, 2001 06:53 AM

How can I write multiple binary chunks to an OutputStream on the servlet response, ensuring each part has the correct contentType/contentLength set?



This is in order to dynamically serve files (mainly .pdf files) held in binary format in an Oracle database.

Re: MultipartOutputStream

Posted By:   Christopher_Schultz  
Posted On:   Wednesday, December 19, 2001 10:19 AM

You'll have to do this manually, setting the content-type of the response to multipart/form-data or whatever and then serving each of your files between 'boundaries'.



You'll have to do your own content-length calculations, which means that this process can get very bulky in memory. Can a database BLOB tell you how big it is? If so (and you trust the value), you could use that value.



As for content-type, you should store the content-type of the file when it was uploaded and inserted into the database. Just create a separate column with the text of the content-type. Just spit this our for each of your parts of your multipart response.



Lastly, consider having the client request these documents one-at-a-time, instead of using a multipart response. I'm not sure how browsers will react to multipart responses. I know that I'd rather see a PDF in my browser window than having to download three of them at once and then run them off my own computer.



Hope that helps,

-chris
About | Sitemap | Contact