jeudi 2 octobre 2014

multiple file upload in grail


Vote count:

0




I am trying to copy multiple files using the request or HttpServletRequest features.


I have been able to loop through all the selected files in a controller action where I have accessed the MultipartFile object for each file - here is the action code:



request.getFileNames().each{
request.getFiles(it).each
{ file ->
// loop through all files selected
println "name: $file.name Originalfilename: $file.originalFilename contentType: $file.contentType"
file.transferTo( new File( userDir, file))
} // eo for loop
} // eo requect.getFiles().each....


I get a groovy runtime error at the transferTo line - the error message being:



Could not find matching constructor for: java.io.File(java.io.File, org.springframework.web.multipart.commons.CommonsMultipartFile)



If I comment out the transferTo line the printout line line the loop produces the correct MultipartFile information about each selected files.


See output for two files selected here:



name: file[] Originalfilename: for-sale.gif contentType: image/gif


name: file[] Originalfilename: front.gif contentType: image/gif



How can I invoke transferTo to do the copy?


-mike



asked 1 min ago







multiple file upload in grail

Aucun commentaire:

Enregistrer un commentaire