I am using Grails 2.4.3, and I have <g:uploadForm> with the method set for publishing, but I do not get MutlipartRequest in my controller action. Instead, I get Servlet3SecurityContextHolderAwareRequestWrapper , which does not have a getFile() method. I tried casting, I tried to get the request from the shell using request.request , and I tried a bunch of other things that, as I saw, I suggested to others with a similar problem, but still not cubes. I'm sure I missed something simple. I tend to do this, but if someone can point me in the right direction, I would be very grateful.
Here is my form:
<g:uploadForm method="POST" action="uploadSupplemental" > <div class="modal-header"> <h3 class="modal-title" id="myModalLabel">Upload Supplemental Data File</h3> </div> <div class="modal-body"> <label for="fileInput">Choose file to upload:</label> <input type="file" id="fileInput" name="supplementalData" /> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> <input type="submit" class="btn btn-primary" /> </div> </g:uploadForm>
And here is my controller action:
def uploadSupplemental() { MultipartRequest multipartRequest = request as MultipartRequest def file = multipartRequest.getFile('supplementalData') if (file){ flash.message = "File found!!" } else { flash.message = "File NOT found. :-( " } redirect action:'list' }
And here is the error I get:
URI / app / upload / uploadSupplemental Class groovy.lang.MissingMethodException Message No method signature: org.springframework.security.web.servletapi.HttpServlet3RequestFactory $ Servlet3SecurityContextHolderAwareRequestWrapper.getFile () values are java Additional data] Possible solutions: getXML (), getPart (java.lang.String), getAt (java.lang.String), getAt (java.lang.String), getLocale (), getJSON ()
spring-security upload grails
Dave klein
source share