I'm about to program a file upload in a Grails app - using g:form with *"multipart/form-data"*. Before saving it to disk, I'll check if the file is bigger than a given number of bytes, in which situation it will be discarded. My concern is: is the temporary file stored in some directory before it is moved to the final destination ? Because if so, I'll need to program some cleaning script for deleting those files.
A:
No temporary files will be created (which need cleaning up) unless you create them explicitly. Just use the getFile() method on the request and get the size of the object in memory before you save (but watch out for out of memory errors):
def imageFile = request.getFile('myFileInputElementId')
if (!imageFile || imageFile.size > 10240) {
...
}
Dave
2010-01-29 14:22:01
A:
You can also try the File Uploader plugin and set the max file size in the configuration...
Philippe
2010-01-29 17:10:16