Monks ~
I'm writing a script which accepts a JPEG upload from a user and, after appropriate checks, stores it for later display. So far so good, thanks in large part to the time I've spent here.
But a little knowledge is a dangerous thing, and I know just enough programming to realize I don't know how best to store or organize these files. Here's what I know (or think I know):
- From what I know of file systems, it's not efficient to dump hundreds of files in the same directory because it dramatically slows search and retreival.
- Thus, I need an algorithm to somehow distribute the uploaded files over a directory structure.
- Um ... that's it.
Left to my own devices I'd make a hard limit on the number of files allowed in a directory and, when that limit's reached, move to a new directory and start to fill it. Lather, rinse, repeat. I'd probably use 3 characters (e.g. "aaa," "aab") for directory names. The server in question is running FreeBSD, and I'm currently trying to find a good number for "max_directory_entries."
From a programming class I took yon these many moons ago (not my degree, obviously), I remember using hash structures for storing and retrieving data. My sense is that this would be overkill for what I need. I'm never going to search these directories, since the database will always know exactly where every image is.
Does anyone have any insight or suggestions?
Thanks!
--
man with no legs, inc.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.