Upload files by convention?

This is a bit of a brain dump, but I was just having an interesting
conversation with Bob Silverberg recently about where we think file
uploads should occur in an OO application. Currently we are both
processing our file uploads by calling a Filesystem object (in my case
the uploadFile() method of the Utilities plugin) from the service
layer.

We concluded that the job of uploading files really belongs in the
controller, and as the controller is an extension of an MVC framework,
maybe the MVC framework could handle the file uploads.

We're thinking that it could work along the lines of the security
interceptor config to handle which handler and permissions are allowed
to upload files. A naming converntion could be used to name form
fields containing file uploads. The result of the upload could be
store in the event collection.

Do you think that this would be a good thing to have as a ColdBox
interceptor?

Bob has posted a more in-depth version to the Model Glue mailing list
which is an interesting read at
http://groups.google.co.uk/group/model-glue/browse_thread/thread/db6893bbe8a9050

Thanks for reading :slight_smile:

I think this is a great case for an interceptor and something customizable. Then you can do your own conventions or whatever you like. Myself personaly, I usually go the way of uploading via the plugin, as 1 line pretty much does it all for me from my controllers or services.

Luis

Thanks for the reply Luis.

If I can give an example of where I think this would be a benefit over
calling the uploadFile() method is when you have a form which allows
for several optional uploads. The uploadFile() method expects the
FileField to contain a file, so you have to check if the form field
contains data and repeat this process for each file upload.

- John