search

Home  >  Q&A  >  body text

java - 在后端存储,比如多媒体文件(音频,视频,图像)是如何存储的?

PHP中文网PHP中文网2807 days ago840

reply all(2)I'll reply

  • 巴扎黑

    巴扎黑2017-04-18 10:38:51

    There are at least two methods:

    Method 1

    It is stored in the database as you mentioned, but 没听过也没见过谁真这么干过.
    The reasons for not doing this are at least the following two points:

    • For example, a picture is about 1M. If there are too many, the size of the database file will expand rapidly

    • The volume of data is large, and it will be very slow to load when querying

    Method 2

    The file is placed on the disk like an ordinary file, and the path of the file in the file system is recorded in the database. 磁盘上,数据库中记录文件在文件系统中的路径
    读取文件的时候,先从数据库读取文件在磁盘上的位置,然后服务器(nginxtomcatWhen reading a file, first read the file's location on the disk from the database, and then the server (nginx or tomcat, etc.) will send the file back to the client.

    A little further:

    For method two, the files are often placed on a dedicated static file server to do 动静分离,感兴趣的话可以搜搜关键字:nginx反向代理.

    For example, you can use nginx or apache to specifically process static files (pictures, videos, etc.). nginxapache来专门处理静态文件(图片,视频等)。
    对于那些实在没办法静态化的请求就由tomcatFor those requests that cannot be static, they will be dynamically processed by tomcat and sent back to the client.

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-18 10:38:51

    • Save it on your own server and do your own distributed storage of files, high availability and so on

    • Call third-party interfaces, such as Paiyun or Alibaba Cloud OSS, without having to operate and maintain it yourself

    reply
    0
  • Cancelreply