开发者

Dealing with mass images, some small - some large, in spring/java application using mysql

开发者 https://www.devze.com 2023-01-29 19:23 出处:网络
I was wondering what the best pattern was to handle the management of images these days when using spring/java and mysql.

I was wondering what the best pattern was to handle the management of images these days when using spring/java and mysql.

  1. I have several options. Some of the images are just small avatars for the users. Is it fine to put these directly into mysql? Or use the file system?

  2. For the larger images, is file system pretty much the only option, and then use mysql to store the location on the file system?

  3. Where is a good spot to put them on a linux server? /var/files/images?

  4. Since the files are hidden from the war deployment directory, what is the best way to stream them? Use some kind of a file output stream as the response body for an http request?

  5. Also, do I have to develop all of the file management stuff myself, like cleaning up 开发者_如何学Gounused files and the like?

  6. What about image security? Some images should not be accessed by everyone. I think I'd need to use a separate url with Spring security checking the current user for this.

I'd appreciate advice on all of these questions. Thanks.


You could use MySQL, and that would have the advantage of centralization and easy cleanup, but IMHO it's a waste of the database's resources if you plan to scale.

For data like images where everything is public, consider something like Amazon S3 which allows you to serve images directly from S3's web servers. If you plan to host everything yourself, just serve from a directory. Just remember to turn directory listings off :)

0

精彩评论

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