Just curious if anyone knows how to handle multipart uploads through jsecurity using the spring framework. I'm using grails with the jsecurity plugin which gives me a JsecurityHttpServletRequest request object when I try to upload a file to a controller. I need some sort of MultipartHttpServletRequest. Any help is appreciated.
~jtrnix
same problem, but recommended solution doesn't seem to work
hi folks
I have the same problem as above - I want to call "getFile" on the request but am getting
missing method because the request is a JsecurityHttpServletRequest
I do have the enctype="multipart/form-data" statement in my form, but no luck :-(
the other wildcard is that I'm using a webflow
I''m on grails 1.0.2
(sorry to again post grails-specific stuff here, but it seems that this thread never moved to grails-user)
thanks!
hamish cunningham
http://www.dcs.shef.ac.uk/~hamish/
Re: same problem, but recommended solution doesn't seem to work
Hi Hamish,
Unfortunately this is a grails issue that I don't know how to resolve :(
Did you try posting to the grails-user list? I'm sorry I can't be of more help. The issues in this thread were resolved by grails users that also happen to be JSecurity users, so you'd probably get more help on the Grails list if you don't get an answer here soon.
Regards,
Les
Re: same problem, but recommended solution doesn't seem to work
thanks lee, I'll try the grails list
best,
hamish cunningham
http://www.dcs.shef.ac.uk/~hamish/
Have you tried the methods
Have you tried the methods described in section 6.1.8 of the Grails user guide? They should work with the JSecurity plugin, although I haven't tried it. If you do have problems, it's best to e-mail the Grails user mailing list - which you can do from Nabble if you don't want to register.
Cheers,
Peter
Hi Peter, Thanks a lot for
Hi Peter,
Thanks a lot for responding even though I have misplaced this post in the wrong forum. I kind of knew that already but grails' web site doesn't provide an easy link to their forums which is a bit of a usability error (ie i have to dig through to the mailing lists section to find it...) and I thought this may just be a general jsecurity/spring framework issue.
In any event, I have tried the methods in the section 6.1.8 of the grails user guide. In fact, I'm trying to get their example to work:
def upload = {def f = request.getFile('myFile')
if(!f.empty) {
f.transferTo( new File('/some/local/dir/myfile.txt') )
response.sendError(200,'Done');
}
else {
flash.message = 'file cannot be empty'
render(view:'uploadForm')
}
}
However, the request object I get is a JsecurityHttpServletRequest and not a multipart form.
I have registered at grails-forum.org now and will post the question there. Thanks for your help!
~jtrnix
Which version of Grails are
Which version of Grails are you using? I have just created a small sample application with JSecurity and a file upload form. Printing the request class gives:
>>> Request class: class org.springframework.web.multipart.support.DefaultMultipartHttpServletRequest
Does the form element in your GSP have the attribute:
enctype="multipart/form-data"
? That's the only thing I can think of. Alternatively, have you configured the Spring MultiPartFilter?
Cheers,
Peter
Hi Peter, Thanks for all
Hi Peter,
Thanks for all your help. You were exactly right about the enctype="multipart/form-data". Truth to be told, I'm using GWT as a front-end and had enabled my form to be a file upload form. However, I forgot I was manually handling the form submission in another class which bypassed my efforts to set the form as a file upload since the form wasn't handling its own submit.
So, problem solved and sorry for the irrelevant post to Jsecurity forums . You guys were a big help nevertheless. Thanks a lot!
~jtrnix
Re: grails jsecurity multipart upload
Hi jtrnix,
I'm assuming you're using Spring's Multipart support?
This support basically wraps/proxies the underlying request object and provides some additional multipart features. So, although JSecurity uses its own JSecurityHttpServletRequest object (which itself also wraps/proxies the servlet container's 'real' HttpServletRequest), the Spring MultipartHttpServletRequest would just wrap ours without any problems.
Unfortunately, I have no idea how grails enables this though - you might want to post that question to the grails user mailing list. The Grails JSecurity plugin is not maintained as a direct part of our project or source code - it is maintained as part of the Grails Plugins project source code. However, the JSecurity Grails plugin creator, Peter Ledbrook, is one of our committers, so I'm sure you'd be able to get good help from him or the other plugin-savvy users on the grails user mailing list.
Cheers,
Les
Hi Les, Yes, I'm using
Hi Les,
Yes, I believe Grails uses spring's multipart request by default, however, with the jsecurity plugin the requests become wrapped by Jsecurity as you mentioned.
I would have thought exactly the same thing as far as spring's MultipartHttpServletRequest wrapping JsecurityHttpServletRequest but I got an exception last night trying to cast.
As I mentioned to Peter, I was kind of hoping this was a generic spring/jsecurity question but it seems to be more of an issue with the plugin and how grails/spring interact.
I'm posting my question to the grails forum now.
Thanks for the help, you guys were quick to respond.
~jtrnix