I will create a portal in J2EE for college students to upload and download data. Data could be any factor like Pdf, doc file, ppt file or could be Image or Video also.
How do i manage Data in database?
Appears like you'll need all ground-up. I'll just give direction, you'll need focus on it, and when there's an issue include specific problem.
Upload files for your file system, or storage, or somewhere like Amazon . com S3. With this use, something similar to Apache FileUpload
Once upload is performed, get the position of the file in which you saved it around the storage-server. Say,
Have your database having a table that stores the metadata concerning the file. Generally it might seem like:
upload_id | file_name | file_location | user_id | timestamp
upload_idmay be the PK,
file_namemay be the submitted file's original title,
file_locationmay be the actual full path from the file where it resides inside your storage,
user_idmay be the uploader's Id, a FK from
The display part: Have your logic to make use of this database to show
To download, you could have something similar to this How to config Tomcat to serve images from an external folder outside webapps? , observe that this isn't restricted to serving image file. It may serve any kind of file.
Now, you'd question, why on the planet shall we be held doing this much painful things rather than just saving it as being binary data in database? Well, I don't want to dive into discussion, Personally, i prefer this method when i think databases are for data, file-systems are for files. Visit a good discussion here: Storing Images in DB - Yea or Nay?
Hope this can help.
I am likely to guess you don't care what format the information is within (which would be to say, you will not query the information in the database level), by which situation you should think about the binary data types.
I can not become more specific not understanding what database back-finish you are using, however, many common names with this data type are
Keep file within the file system re-named towards the record id in which the file title is saved. This really is less overhead and enables a much better virus checking "you submitted the abc virus".
You may also do methods like storing large files on another server. Backup copies are simpler.