Re: SISCweb & File Upload
"Alessandro Colomba" <[email protected]> Tue, 22 Jul 2008 00:52:09 -0400
| Newsgroups | gmane.comp.java.sisc.user |
|---|---|
| Message-ID | <[email protected]> |
Gerardo, You're right, I had forgotten that in J2EE the HttpServletRequest.getParameter*() methods don't handle multipart requests. The FileUtil library however allows you to read that information with the readHeaders() call. It's a bit clunky, with Iterators and the such, but consider that: 1) The (get-bindings) procedure returns a plain Java Map as per [1]. This is not ever going to change. 2) You can implement your (get-bindings/multipart) procedure either as a wrapper around some Java code that extracts a parameter Map from the FileUpload MultiPartstream, or directly, and somewhat naturally, using the (iterator/for-each) procedures in the util/misc module. [2] Sorry this couldn't be any simpler. ___ Alessandro [1] http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletRequest.html#getParameterMap() [2] http://siscweb.cvs.sourceforge.net/siscweb/siscweb/scm/util/misc.scm?revision=1.4&view=markup&pathrev=rel-0-6-dev On Mon, Jul 21, 2008 at 3:27 AM, Gerardo Horvilleur <[email protected]> wrote: > I've been doing a few tests and I have a problem. In order to be able > to upload files y must declare the form's enctype to be > multipart/form-data: > > (form (@ (action ,k-url) (enctype multipart/form-data)) ... > > But, once I do this, get-bindings isn't able anymore to extract the > bindings from the request object. It just returns an empty map. > > On Sun, Jul 20, 2008 at 11:16 PM, Alessandro Colomba <[email protected]> wrote: >> Gerardo, >> >> The request object returned by the some of the send-*/* procedures is >> the actual HttpServletResponset object. You can most certainly place >> more than one call to it. >> >> The response object is also always available through the >> (current-response) procedure in the siscweb/response module. [*] So >> your file upload module does not technically need to be passed the >> response object, and you can keep the (get-bindings) call n place. >> >> Hope this helps, >> ___ >> Alessandro >> >> [*] http://siscweb.sourceforge.net/swm/ch08.html#response >> >> >> >> On Sun, Jul 20, 2008 at 1:38 AM, Gerardo Horvilleur <[email protected]> wrote: >>> The Apache Commons File Upload library is what I have used in other >>> projects written in Java. >>> >>> So, it looks like I''ll have to do something like >>> >>> (let ((request (send-thml/suspend ... >>> >>> instead of doing >>> >>> (let ((bindings (get-bindings (send-html/suspend ... >>> >>> so I can give the request to the file upload library to extract the data. >>> >>> What I don't know is if, after I've used the request object with the >>> file upload library, I still can do a a >>> >>> (let ((bindings (get-bindings request))) ... >>> >>> To extract the values for the parameters which are not file uploads. >>> >>> All the pages in which I need to support file uploads also have many >>> other fields, and I would like to still be able to use get-bindings to >>> handle them. >>> >>> On Sat, Jul 19, 2008 at 8:31 PM, Alessandro Colomba <[email protected]> wrote: >>>> Gerardo, >>>> >>>> Unfortunately file uploads in J2EE are best handled through >>>> third-party libraries, and I really did not want to tie SISCweb to >>>> one. Apache Commons has a pretty good library (FileUpload), and I >>>> wouldn't imagine difficult to write a Scheme wrapper around it. >>>> >>>> Should you decide to go this route, and encounter any obstacles in >>>> SISCweb, please let me know. I'll be glad to clear them out. >>>> >>>> Regards, >>>> ___ >>>> Alessandro >>>> >>>> >>>> >>>> >>>> >>>> On Sat, Jul 19, 2008 at 6:14 PM, Gerardo Horvilleur <[email protected]> wrote: >>>>> For the application I'm writing, I need to let the user upload images >>>>> to the server. I haven't found any straightforward way to handle file >>>>> uploads in SISCweb. Has anybody already written some code to handle >>>>> this? >>>>> >>>>> -- >>>>> Gerardo Horvilleur >>>>> [email protected] >>>>> 5813-0830 >>>>> >>>>> ------------------------------------------------------------------------- >>>>> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge >>>>> Build the coolest Linux based applications with Moblin SDK & win great prizes >>>>> Grand prize is a trip for two to an Open Source event anywhere in the world >>>>> http://moblin-contest.org/redirect.php?banner_id=100&url=/ >>>>> _______________________________________________ >>>>> Sisc-users mailing list >>>>> [email protected] >>>>> https://lists.sourceforge.net/lists/listinfo/sisc-users >>>>> >>>> >>> >>> >>> >>> -- >>> Gerardo Horvilleur >>> [email protected] >>> 5813-0830 >>> >> > > > > -- > Gerardo Horvilleur > [email protected] > 5813-0830 > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/