Getting a PDF(BLOB) into a BlobDomain and turning it into an InputStream
582466Oct 14 2011 — edited Oct 14 2011Hello,
I have PDFs stored in a database under the BLOB datatype, and I need to turn it into an InputStream.
I first get the PDF from the database and save it as a BlobDomain.
BlobDomain fileBlobDomain = (BlobDomain)prow.getAttribute("FileData");
Getting the data from the database seems to be successful as when I print fileBlobDomain.getLength(), it returns a real value.
System.out.println("fileBlobDomain size is " + fileBlobDomain.getLength()); --> returns a valid value
However, once I try to get a InputStream from the fileBlobDomain, the InputStream seems to be empty:
InputStream PdfInputStream = fileBlobDomain.getBinaryStream();
System.out.println("available is " + PdfInputStream.available()); --> available is always 0.
Has anyone had similar problems getting PDFs from a database and converting it into an InputStream? I looked everywhere for solutions, but most other solutions seemed to be doing exactly what I was doing above.
I would really appreciate any insight into this problem.
Thank you!