wood burning stoves 2.0*
The moose likes Servlets and the fly likes downloading files from database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "downloading files from database " Watch "downloading files from database " New topic

downloading files from database

J Das
Ranch Hand

Joined: Jul 27, 2011
Posts: 83

hi everyone.. I have a question regarding file downloading. I am developing a file sharing website where users can upload and download files.. while i have finished the uploading part, i am a bit worried with the downloading part.. while uploading , i passed the file path to database when the uploading of a file occurs.. now how can i download a file using just the path in the database ? i mean there isn't the actual file in the database but just the file path.. i hope you all are getting my question.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60782

Write a servlet that reads the file path from the database, opens the file, and streams the contents as the response after setting the appropriate content headers.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ram Narayan.M
Ranch Hand

Joined: Jul 11, 2010
Posts: 247

To speed up the file path information retrieval, why could'nt you try storing these information in Apache Lucene Indexing?... When no. of file increases per user, searching for file path information takes more time... You can give a try using Apache Lucene..

SCJP 6 [SCJP - Old is Gold]
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60782

Before adopting something like Lucene, there's have to be a clear and demonstrable use case for it. We have seen nothing in this thread that indicates that looking up the file path is any performance burden whatsoever or that search indexing is even called for.
Tim Moores

Joined: Sep 21, 2011
Posts: 2408
Agree with Bear. While Lucene can store non-indexed binary data (like files), that's not what it's meant for, and it's very unlikely to be more efficient at that than using the file system. There might be a case for using Lucene for storing file meta data and the file path -it would indeed be very useful for indexing the file contents, if that's part of the site- but not for storing entire files.
I agree. Here's the link: http://aspose.com/file-tools
subject: downloading files from database
Similar Threads
Problem in Checking file transfer completion throgh FTP
JFileChooser it loads slowly
Serialization in java
Saving File to Client Machine.
Download .mdb File