This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Document Retrival from database. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Document Retrival from database." Watch "Document Retrival from database." New topic
Author

Document Retrival from database.

Vishal Kumar Aruru
Greenhorn

Joined: May 18, 2009
Posts: 8
Hi,

I have a requirement of uploading the file like .doc, .xls, .jpeg, .txt, .gif, .pdf into database. so, i uploaded the file by converting them into bytearray and then to database like blob. Up to here it is fine. My problem is view the file. i.e. i know the file extension and i will get the byteArray from the database to the presentation layer. I need a logic such that i can use this byteArray and file extension to show the file like for example, if i upload a image, it converts to bytearray and then to blob to database. then i retrieves the bytearray from the database and i have to convert this byte array to image. similarly to .doc, .xls, .jpeg, .txt, .gif, .pdf.

Thanks in Advance.
Ronald de Gier
Greenhorn

Joined: Sep 09, 2009
Posts: 9
Could you perhaps create a temp file with the given extension, stream the bytes in, and launch the proper application with the filename as parameter?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

Ronald de Gier wrote:launch the proper application with the filename as parameter?

Using Desktop.open of course.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Vishal Kumar Aruru
Greenhorn

Joined: May 18, 2009
Posts: 8
I am not understanding what you are saying, i will get a raw byte array, and how can i make generic one to open the file, i am bit confused, can you tell me scenario or any junk code such that i feel comfortable.
thanks in advance.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41137
    
  45
The key question is, what do you intend to do with those files? Stream them to the client? Show a preview? Process them on the server?


Ping & DNS - my free Android networking tools app
Vishal Kumar Aruru
Greenhorn

Joined: May 18, 2009
Posts: 8
Thanks for your concern,

I want to show preview, thats it
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41137
    
  45
Preview for random file types is tough. Images are easy (load them using ImageIO.read, scale the BufferedImage to your heart's content, save it to a public directory, and embed it in the page); but everything else is a different story.

The PDF-Renderer library can display PDFs in a Swing component; you should be able to render that into a BufferedImage, at which point it's the same as what I mentioned above for images in general.
 
 
subject: Document Retrival from database.
 
Similar Threads
file download from JSP
File uploading using Servlet / JSP
Surprising .. "Member Not Found"
jpa2web with tomcat problem
problem uploading file in oracle databse