开发者

Determining Path of MultipartFile in Groovy

My Grails app is successfully uploading then parsing a MultipartFile with the following code:

def file = request.getFile('rawReport')
def report = new XmlSlurper().parse(file.inputStream)

My Problem: I need the path of the original file ('rawReport'), can see path information in the Debugger's "Expression" View, but can't find a method that will return the file's path as I need it.

I've found loads of "methods of the sort I'd like to have" here but they'r开发者_JAVA技巧e all for simple Files, not MultipartFiles. I felt a surge of hope when I found "getStorageDescription" for MultipartFiles here but that hope was dashed when it returned "in memory" (literally... what good is that?!)

It's frustrating because I can see pieces of what I could use in the debugger... STS Expression View: Name:file -> repository -> path "\\home$\Happiness\Awaits\You\Here..."

Any help would be most appreciated.


In general it's not available as described in the Javadoc for the getOriginalFilename() method: http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/web/multipart/commons/CommonsMultipartFile.html#getOriginalFilename%28%29

I'm guessing that this is a security issue. I found that it behaved for me as described for Firefox and Chrome, and even Opera didn't include the full path. So even if you can get the information locally you wouldn't be able to trust that the full path would be available in general.

You might look for a Flash-based uploader which wouldn't be constrained by browser restrictions.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜