开发者

Temporary uploaded file location in grails

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'l开发者_JAVA技巧l need to program some cleaning script for deleting those files.


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) {
        ...
    }


You can also try the File Uploader plugin and set the max file size in the configuration...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜