my dog learned polymorphism
The moose likes Servlets and the fly likes downloading files from database Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "downloading files from database " Watch "downloading files from database " New topic
Author

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
Marshal

Joined: Jan 10, 2002
Posts: 56183
    
  13

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.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Ram Narayan.M
Ranch Hand

Joined: Jul 11, 2010
Posts: 244

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
Marshal

Joined: Jan 10, 2002
Posts: 56183
    
  13

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
Rancher

Joined: Sep 21, 2011
Posts: 2407
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
Saving File to Client Machine.
JFileChooser it loads slowly
Download .mdb File
Serialization in java