开发者

attaching multiple files to a domain class

开发者 https://www.devze.com 2022-12-23 03:08 出处:网络
I\'ve seen various Grails plugins which allow easier handling of file uploads, however these tend only to support a single file per form-submit.

I've seen various Grails plugins which allow easier handling of file uploads, however these tend only to support a single file per form-submit.

I'd like a multi-attach form where as soon as you pick one file, an extra field and b开发者_开发知识库utton is added using JS (various sites do it like this).

Do you know of any good plugins which provide elegant uploading of multiple files without excessive coding? A progress bar either per-file of for the whole process would also be very nice.

I don't know to what extent I can allow GORM to handle a java.io.File field (or in this case a Collection<File>).


Try this tutorial - it uses a combination of jQuery and Flash: http://webdeveloperplus.com/jquery/multiple-file-upload-with-progress-bar-using-jquery/

Though it's no Grails Plugin; but it doesn't matter as the plugin wouldn't do anything different (just adding some convenience tags and configs, probably).

Your second part of the question: How to save the files with your domain class. My advise: don't do that. If it's just a single thumbnail you want to store it would be fine. But as soon you have multiple/big files stored it just slows down your DB. Store binary data on the file system and reference their path+filename in the domain:

class UploadedFile {

  String name
  String pathToFile
  String fileType
}
0

精彩评论

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