A few years ago I worked on an electronic document management system, and we did a lot of what Gamecat and wic suggested.
That is, assign a unique identifier to each image and use it to get the relative path to the image file. We used MOD in the same way as wic suggested, but we allowed 1024 folders / files at each level with 3 levels, so we could support 1G files.
However, we removed the extension from the files. Database records contained a MIME type, so no extension was required.
I would not recommend storing the full URL in the database entry, only the Image ID. If you are storing a URL, you cannot move or restructure the repository without converting your database. The relative URL will be approved, as you can at least move the image repository, but you will get more flexibility if you just save the identifier and get the URL.
In addition, I would not recommend allowing direct links to your image files from the Internet. Instead, specify the URL of the server program (for example, Java Servlet), and the image identifier will be specified in the URL request ( http://url.com/GetImage?imageID=1234 ).
A servlet can use this identifier to search for a record in the database, determine the MIME type, obtain the actual location, check security restrictions, logging, etc.
Clayton Jan 15 '09 at 13:07 2009-01-15 13:07
source share