Please Try to Understand my curiosity
Suppose there is a web application that has mannny users. Each user can upload hundreds
of images and after logged in to his/her account can see those images according to his
will.
E.g – The social networking sites like Facebook.
So what my Question is
- How do they store so many images in their servers ?
- in database as BLOB data ? OR
- in dedicated folders in server for each user ?
- If I choose to use database then
- Should I retrieve the images from database, copy them into a temporary folder in server and
get the images through <img src=’/serverpath/image ‘> tag for each session ?
- Should I retrieve the images from database, copy them into a temporary folder in server and
So How do they store and retrieve ?
Now in my application there are user details(without photos) and whenever I click on “view image”
link the photo should appear without page refresh. How can I achieve this using Java as per my above concerns regarding storage and retrieval ?
Save image in a folder, rename image to add some user specified id ect. to picture, so you cant have two picture with same id. Then save path in to database.
I would suggest to use something like ImageMagick to do the image saving to folder. It can change the name of image and if you want you can change it format and size.
When you want to show pictures to user just get that path from a database, wich have that specified user id to show pictures wich belongs to user.
Saving images directly to database is not good choice if you really have millions pictures like facebook have.
And I dont think you can do that image appearing with java, I suggest using javascript and ajax for it. Check this page for help, http://www.w3schools.com/ajax/ajax_example.asp