1
votes

I am getting an error when uploading a file with UTF-8 characters as multipart/form-data in Grails.

I am using the Form below;

<form action="uploadPost" enctype="multipart/form-data; charset=utf-8" method="POST">
    <label class="form-titles" for="csvList">Choose a file: </label>
<input type="file" id="csvList" name="csvList" style="width: 200px;"/>
    <input type="submit"/>

In the controller I have:

def file = request.getFile('csvList')

This causes the error:

ERROR [org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver] - No signature of method: org.springframework.security.wrapper.SavedRequestAwareWrapper.getFile() is applicable for argument types: (java.lang.String) values: [userList] Possible solutions: getXML(), getAt(java.lang.String), getAt(java.lang.String), getLocale(), getLocale(), getJSON()>

I think this will be same in Java.

Any idea what I am doing wrong and how to get UTF-8 charset in multipart form?

2
Can you post the full stacktrace? - user800014
Full stacktrace --- groovy.lang.MissingMethodException: No signature of method: org.springframework.security.wrapper.SavedRequestAwareWrapper.getFile() is applicable for argument types: (java.lang.String) values: [userList] Possible solutions: getXML(), getAt(java.lang.String), getAt(java.lang.String), getLocale(), getLocale(), getJSON() at UserController$_closure14.doCall(UserController:284) at UserController$_closure14.doCall(UserController) at java.lang.Thread.run(Thread.java:680) - bdev

2 Answers

0
votes
enctype="multipart/form-data"

Don't put a charset in the "enctype" attribute.

0
votes

I think that's because you declared the utf8 inside the enctype and the server didn't understand as a multipart. Try:

<form method="post" action="uploadPost" enctype="multipart/form-data" accept-charset="UTF-8">