Grails uploads unsigned file for getFile () method

I implement a simple form with input and file upload fields. I looked through the tutorial: http://grails.org/Simple+Avatar+Uploader and the documentation: http://grails.org/doc/2.0.x/guide/theWebLayer.html#uploadingFiles

However, downloading the file does not work! Why is this not working? Any solutions to the problem?

Question:

No method signature: org.springframework.security.web.servletapi.HttpServlet3RequestFactory $ Servlet3SecurityContextHolderAwareRequestWrapper.getFile () is applicable for argument types: (java.lang.String) values: [itemImage] Possible solutions: getXML (), Java.lava (), Java.lava ()) .String), getAt (java.lang.String), getAt (java.lang.String), getLocale (), getJSON (). Stacktrace follows: Message: No method signature: org.springframework.security.web.servletapi.HttpServlet3RequestFactory $ Servlet3SecurityContextHolderAwareRequestWrapper.getFile () applicable for argument types: (java.lang.String) values: [itemImage] Possible: getMLage] getPart (java.lang.String), getAt (java.lang.String), getAt (java.lang.String), getLocale (), getJSON () Line | method →> 14 | save to greatoffer.SellController $$ EOVmPG4d - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 195 | doFilter at grails.plugin.cache.web.filter.PageFragmentCachingFilter | 63 | doFilter at grails.plugin.cache.web.filter.AbstractFilter | 53 | doFilter at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter | 49 | doFilter in grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter | 82 | doFilter in grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter | 895 | runTask in java.util.concurrent.ThreadPoolExecutor $ Worker | 918 | run at '' ^ 662 | run., in java.lang.Thread

Main GSP:

<g:uploadForm action="save" method="POST"> <fieldset class="form"> <g:render template="form"/> </fieldset> <fieldset class="buttons"> <g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}" /> </fieldset> </g:uploadForm> 

Download image of part of the GSP form:

 <label for="images"> <g:message code="item.images.label" default="Images" /> </label> <input type="file" name="itemImage" /> 

Controller:

 import grails.plugin.springsecurity.annotation.Secured @Secured('permitAll') class SellController { def index() { render(view: "seller") } def save() { println "Here are params: ${params}"; def f = request.getFile('itemImage') flash.message = message(code: 'default.created.message', args: [message(code: 'item.label', default: 'Item'), params.id]) render(view: "seller") } } 
+3
file-upload grails
source share
1 answer

By the type of your stack trace, Spring Security @Secured annotation completes your request in SecurityContextHolderAwareRequestWrapper . You should get MultipartHttpServletRequest to call getFile, I believe.

Also in your debugging Here is the params instruction, do you see itemImage? If so, I actually think it can be easy.

 def file = params.itemImage 

UPDATE: I supported the comments. They were not there when I started typing.

+5
source share

All Articles