[Html-widget] formfu - file uploads

Carl Franks fireartist at gmail.com
Tue Mar 20 15:00:53 GMT 2007


okay, after several different attempts over the past few days, I've
got file uploads working with what I think is a sane API.

* From the end user's point-of-view (someone who's using the $form object):
File uploads are accessed via $form->param() or $form->params() just
like any other submitted value.
Each file is a subclass of HTML::FormFu::Upload. (The blessed class
differs according to whether you're using CGI, CGI::Simple or
Catalst).
Each file object has the following methods: filename(), headers(),
fh(), slurp().

If you have any Inflators or Transformers registered with the file
field, then the value returned by param() or params() could be of a
different object type.
For example, if you use the Imager Inflator, you should expect param()
to return an Imager object, not a HTML::FormFu::Upload object.
This is the intended behaviour.

* From an Inflator / Transformer developer's point-of-view:
To provide compatabililty between Catalyst / CGI / CGI::Simple you
should always access the uploaded file via $file->fh() or
$file->slurp.
Inflators and Transformers should return a new value.
It's up to the form-user to put Inflators in a sane order, and to use
appropriate Transformers for the Inflators used.

TODO:
provide Catalyst::Request compatible $form->uploads() and
$form->upload() methods.
Catalyst tests.

Carl



More information about the Html-widget mailing list