Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>One possible way would be to calculate the MD5 signature of the file (or the file ID in a database), and then build/find the path based on that.</p> <p>For example, say we get an MD5 signature like "1ff8a7b5dc7a7d1f0ed65aaa29c04b1e"</p> <p>The path might look like "/1f/f" or "/1f/ff/8a"</p> <p>The reason is that you don't want to have all the files in 1 folder, and you want to have the ability to "partition" them across different servers, or a SAN or whatever in an equally-spread-out way.</p> <p>The MD5 signature is a string of 16 "hex" characters. So our example of "/1f/ff/8a" gives us 256*256*256 folders to store the files in. That ought to be enough for anybody :)</p> <hr> <p>Update, due to popular demand:</p> <p><strong>NOTE</strong> - I just realized we are talking specifically about how MediaWiki does it. This is <strong>not</strong> now MediaWiki does it, but another way in which it <strong>could have been done</strong>.</p> <p>By "MD5 signature" I mean doing something like this (code examples in Perl):</p> <pre><code>use Digest::MD5 'md5_hex'; my $sig = md5_hex( $file-&gt;id ); </code></pre> <p>$sig is now 32 alpha-numeric characters long: "1ff8a7b5dc7a7d1f0ed65aaa29c04b1e"</p> <p>Then build a folder structure like this:</p> <pre><code>my $path = '/usr/local/media'; map { mkdir($path, 0666); $path .= "/$_" } $sig =~ m/^(..)(..)(..)/; open my $ofh, '&gt;', "$path/$sig" or die "Cannot open '$path/$sig' for writing: $!"; print $ofh "File contents"; close($ofh); </code></pre> <p>Folder structure looks like</p> <pre><code>/ usr/ local/ media/ 1f/ f8/ a7/ 1ff8a7b5dc7a7d1f0ed65aaa29c04b1e </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload