So I've been hacking a lot on a new file upload module and am ready to get some feedback on it on it. An introduction is below. You can also browse the documentation, or check out some recipes for a complete application. Feedback appreciated!
CGI::Uploader is designed to help with the task of managing files uploaded through a CGI application. The files are stored on the file system, and the file attributes stored in a SQL database.
A Little History
The release of this module represents a culmination of seven years of experience mananging file uploads as a professional website developer for Summersault, LLC (http://www.summersault.com/). Over that time I noticed patterns that were re-usable from project to project. I went through serveral versions and rewrites of modules that attempted to be 'generic' and not need modification when the next project came along. With CGI::Uploader, I believe I finally have a solution that I will continue to be happy with and I think others will be find generally useful. Enjoy!
Freedom of Choice
I have strived to make CGI::Uploader to work within a variety of system designs. It offers you freedom choice in the following areas:
MySQL and Postgres are supported directly. The SQL used is very simple-- support for additional databases should be trivial.
The query object used may provided by
Another source could be used by overriding the
For small projects,
all uploads can be stored in a single directory.
For large projects,
we provide the
md5 file scheme,
which should scale well to millions of images,
without burdening any single directory with storing too many of them.
Because the meta data is stored in a straightforward SQL database table,
you can retrieve your data and display in any number of custom ways.
Several functions are also built in to help with common display tasks.
build_loc() method is used to construct the file system or URL path of an image,
given it's ID and extension.
fk_meta() provides an easy way to get the meta data of an upload by relating it to a foreign key in another table.
transform_meta() is a basic function which tranforms a hashref of data from the database into a format more useful for display,
producing a hash that looks like this:
my_id => 523,
my_url => http://localhost/images/uploads/523.pdf?32,
my_width => 23,
my_height => 46,
CGI::Uploader works with all types of file uploads, it contains a number of features to help with common tasks associated with image uploads.
Image::Magick is the preferred image processing module for to use when creating the thunbmails. Support for
GD is in progress.
GD supports many fewer formats, but also has much fewer dependencies to get installed than
Image::Magick does. Another providers could be used by extending or overriding the
Just Three Essential Methods to Learn
A goal of CGI::Uploader; is to provide a high-level interface to make managing file uploads easy. Only three methods are needed to manage all the functions needed to store, update, delete and view the uploads attached to sme database entity. Those methods are
More methods when you need them
When your needs before more complex, you can call the lower-level functions in
CGI::Uploader to meet your needs. Most functions use file names to access file uploads, so it's easy to use the module to manipulate files from other sources than the browser upload field.
For example, the
gen_thumb() method is general purpose thumbnail creating routine.