在 spring/java 应用程序中使用 mysql 处理大量图像,有些小,有些大

发布于 2024-10-07 09:54:25 字数 497 浏览 0 评论 0原文

我想知道现在使用 spring/java 和 mysql 时处理图像管理的最佳模式是什么。

  1. 我有几个选择。一些 图像只是小头像 用户。放这些可以吗 直接进入mysql?或者使用该文件 系统?

  2. 对于较大的图像,是文件 系统几乎是唯一的选择, 然后使用mysql来存储 文件系统上的位置?

  3. 哪里是放置它们的好地方 一个Linux服务器? /var/files/images?

  4. 由于文件是隐藏的 war部署目录,是什么 流式传输的最佳方式是什么?使用 某种文件输出流 http 的响应正文 请求?

  5. 此外,我是否必须开发所有 我自己的文件管理工作, 比如清理未使用的文件和 之类的?

  6. 图像安全怎么样?有些图像不应该被所有人访问。我想我需要使用一个单独的 url,Spring 安全性检查当前用户的情况。

对于所有这些问题,我希望得到建议。谢谢。

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 unused 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

简美 2024-10-14 09:54:25

您可以使用 MySQL,这将具有集中化和易于清理的优点,但恕我直言,如果您计划扩展,这会浪费数据库资源。

对于图像等所有内容都是公开的数据,请考虑 Amazon S3 之类的数据,它允许您直接从 S3 的 Web 服务器提供图像。如果您打算自己托管所有内容,只需从目录中提供服务即可。请记住关闭目录列表:)

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 :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文