开发者

Retrieving images when database is in remote location

I am developing an application using Java, my application would be accessed by number of different users simultaneously and the database resides in a central server. The access of the database from remote server is handled by just giving the appropriate IP of the server in the Hibernate configure file.

My question is, I have to store a picture regarding each user of the database, I hea开发者_如何学Gord that storing the image in the database and retrieving it from the database is not advised and has negative impact on the performance. Is it so?

What are the other possible ways i can implement this? What is the best way to do it?


well, store the images at app server in file system and save it's reference to users table's image_location column. refer: Photo storage for web app


Side Note: If you have multiple app server, better store the files at a shared location accessible to all the app server in indentical manner. It's not a good idea to store file in database.


As indicated by @sasidhar, here is what I would do:

  1. Make a central image server with Unix OS on it. Will make sure it has fixed IP.
  2. In your app, use JSch to secure copy file from client machine to a dedicated directory at the server
  3. Update the users table's image_location with relative path of the image from "/"
  4. When viewing, I will check the relative path of the user and fetch it again using JSch secure file tranfer protocol.

By the way, setting up a FTP could be a better alternative.


Why should you not use DB as file storage? See here: Storing Images in DB - Yea or Nay?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜