[
  {
    "Id": "606427",
    "ThreadId": "256143",
    "Html": "\r\n<p>I need to allow visitors to download PDF files that are compressed and stored in an Oracle database as a BLOB.&nbsp; I am trying to find a way to uncompress the data that I retrieve from the database and send it to directly to Response.Write instead of the\r\n file stream.&nbsp;</p>\r\n<p>Thanks in advance for any help.</p>\r\n<p>&nbsp;</p>\r\n",
    "PostedDate": "2011-05-03T06:51:35.637-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "608945",
    "ThreadId": "256143",
    "Html": "<p>Sounds great; what exactly is the format in the Oracle db?&nbsp; You said that they are \"compressed\" - but compressed <em>how</em>?&nbsp; Are they ZIP files, stored in the column?&nbsp;</p>\r\n<p>I've seen <a href=\"http://stackoverflow.com/questions/5678666/unzip-from-a-sql-server-text-column-to-an-image-column\">other examples where there is ZIP data in a database</a>, stored as base64, or just as a hex-encoded string.&nbsp; If that's the case you will need to do a conversion from the in-database representation to a stream of bytes.</p>\r\n<p>Supposing that you are able to get access to a readable stream from the database that supplies the stream of bytes that defines a zip file (not a gzip, not some other compression), then you could do something like this:</p>\r\n<div style=\"color: black; background-color: white;\">\r\n<pre><span style=\"color: blue;\">using</span> (<span style=\"color: blue;\">var</span> zis = <span style=\"color: blue;\">new</span> ZipInputStream(databaseStream))\r\n{\r\n    <span style=\"color: blue;\">byte</span>[] buffer= <span style=\"color: blue;\">new</span> <span style=\"color: blue;\">byte</span>[2048];\r\n    <span style=\"color: blue;\">int</span> n;\r\n    ZipEntry e;\r\n    <span style=\"color: blue;\">while</span> (( e = zis.GetNextEntry()) != <span style=\"color: blue;\">null</span>)\r\n    {\r\n        <span style=\"color: blue;\">if</span> (e.FileName != <span style=\"color: #a31515;\">\"MyDesiredFile.pdf\"</span>) <span style=\"color: blue;\">continue</span>;\r\n        <span style=\"color: blue;\">while</span> ((n= input.Read(buffer, 0, buffer.Length)) &gt; 0)\r\n        {\r\n            Response.OutputStream.Write(buffer,0,n);\r\n        }\r\n    }\r\n}\r\n\r\n</pre>\r\n</div>",
    "PostedDate": "2011-05-07T06:41:26.087-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]