List, I find the following situation one which arises many times for me when creating modperl applications for people. However, I always find myself thinking there is a better way to do it. I wondered if the list would like to share their thoughts on the best way. It concerns storing and serving images/media uploaded by users of the webpage.
An example could be a website letting you set up your own shops to sell products. The shop maker may allow you to upload preview images of products. Assuming the product data is stored in a database, I personally wouldnt store the binary image in the databas (assuming mysql here). A solution springing to mind is to store a hash/id in the database and have a common directory (/htdocs/_previews/) which holds the pictures named after that hash/id. That way, either the modperl application can auto create the link using src=/htdocs/_previews/imageid.jpg or a lightweight handler can be used. For example /getimage?id=asdf09sd8fsa could then rewrite the uri to the real location or perform a content subrequest and let apache serve the image that way. Of course there are many solutions, but I'm wondering. Is there a best one? Any thoughts appreciated. I realise that the same situation might occur using vanilla cgi, but mod_perl provides unique ways of solving the problem, hence I post to this list. Richard.