Thousands of images, how should I organize the directory structure? (linux)

前端 未结 6 1071
一向
一向 2020-12-07 23:31

I am getting thousands of pictures uploaded by thousands of users on my Linux server, which is hosted by 1and1.com (I believe they use CentOS, but am unsure of the version).

6条回答
  •  有刺的猬
    2020-12-08 00:31

    I would do the following:

    1. Take an MD5 hash of each image as it comes in.
    2. Write that MD5 hash in the database where you are keeping track of these things.
    3. Store them in a directory structure where you use the first couple of bytes of the MD5 hash hex string as the dir name. So if the hash is 'abcdef1234567890' you would store it as 'a/b/abcdef1234567890'.

    Using a hash also lets you merge the same image uploaded multiple times.

提交回复
热议问题