Hi All, I started looking into implementing FormParam support for MSF4J. AFAIU we need to support below content types
1. application/x-www-form-urlencoded 2. multpart/form-data For the *application/x-www-form-urlencoded * This is pretty much similar to the QueryParam. We can read the Request body and get the encoded string and process that as a key-value pair. For the *multpart/form-data* We can implement the multpart/form-data support to cater requests like file upload. Rather than decoding multipart content by ourselves we can use a multipart/form-data parsing library to parse the raw HTTP body. Following apache libraries can be used for this purpose 1. Apache Clerezza [1] 2. Apache Commons-Fileupload [2] As discussed in early in the thread we can't use Commons-Fileupload out of the box to cater our requirements. But we can get the code and modify the to tally with our implementation and work on the FormParam implementation. [1] - https://clerezza.apache.org/ [2] - https://commons.apache.org/proper/commons-fileupload/ Thanks On Wed, May 11, 2016 at 11:31 AM, Samiyuru Senarathne <[email protected]> wrote: > When I was looking into form processing in MSF4J, I was looking at > modifying apache commons [1][2] to meet our needs since it has multipart > support and it is widely used with servlets. But IMO we wont be able to use > it directly out of the box as a library to parse the byte buffer we have > because it starts processing from a servlet request object. > > [1] - https://commons.apache.org/proper/commons-fileupload/using.html > [2] - https://commons.apache.org/proper/commons-fileupload/streaming.html > > On Wed, May 11, 2016 at 11:18 AM, Himasha Guruge <[email protected]> > wrote: > >> In C4 we have used [1] for this purpose. >> >> [1] http://cxf.apache.org/docs/jax-rs-multiparts.html >> >> On Wed, May 11, 2016 at 11:12 AM, Afkham Azeez <[email protected]> wrote: >> >>> Any libraries you are familiar with? Since BPS folks are using the code >>> from the MSF4J master branch, we may be able to quickly implement it. >>> >>> On Wed, May 11, 2016 at 11:09 AM, Samiyuru Senarathne <[email protected] >>> > wrote: >>> >>>> Hi Azeez, >>>> >>>> Yes I looked at this sometime back. But it was not progressed to the >>>> implementation level. >>>> >>>> For the moment we will have to use a multipart/form-data parsing >>>> library to parse the raw HTTP body. We can get the raw HTTP body by >>>> injecting an org.wso2.msf4j.Request object to the resource method using >>>> @Context annotation. >>>> >>>> Best Regards, >>>> Samiyuru >>>> >>>> On Wed, May 11, 2016 at 11:02 AM, Afkham Azeez <[email protected]> wrote: >>>> >>>>> Samiyuru, >>>>> You looked at this some time back right? What work is involved in >>>>> implementing this? >>>>> >>>>> Azeez >>>>> >>>>> On Wed, May 11, 2016 at 11:00 AM, Himasha Guruge <[email protected]> >>>>> wrote: >>>>> >>>>>> From the offline discussion with Azeez, it seems that this is not >>>>>> supported in current msf4j implementation. How are we to proceed with the >>>>>> use case of acquiring form field values from the request? >>>>>> >>>>>> >>>>>> >>>>>> On Wed, Apr 6, 2016 at 11:22 AM, Himasha Guruge <[email protected]> >>>>>> wrote: >>>>>> >>>>>>> Hi All, >>>>>>> >>>>>>> I have gone through the available sample [1] on how to process a >>>>>>> stream and read and save files in msf4j. However given a request with >>>>>>> form >>>>>>> fields like [2] , how can we retrieve those form fields in msf4j? If it >>>>>>> is >>>>>>> to read from the stream itself, any suggested way to do this? >>>>>>> >>>>>>> [1] >>>>>>> https://github.com/wso2/msf4j/blob/652435ee7f8fdf31307667adb888e9a13513f6d8/samples/petstore/microservices/fileserver/src/main/java/org/wso2/msf4j/examples/petstore/fileserver/FileServerService.java >>>>>>> >>>>>>> [2] curl --form >>>>>>> "fileupload=@Desktop/bigdot.png;filename=desired-filename.txt" --form >>>>>>> param1=value1 --form param2=value2 >>>>>>> http://localhost:8080/bps/repo/stream >>>>>>> >>>>>>> Thanks, >>>>>>> >>>>>>> Himasha Guruge >>>>>>> *Software Engineer* >>>>>>> WS*O2* *Inc.* >>>>>>> Mobile: +94 777459299 >>>>>>> [email protected] >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Himasha Guruge >>>>>> *Software Engineer* >>>>>> WS*O2* *Inc.* >>>>>> Mobile: +94 777459299 >>>>>> [email protected] >>>>>> >>>>>> _______________________________________________ >>>>>> Dev mailing list >>>>>> [email protected] >>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>>>>> >>>>>> >>>>> >>>>> >>>>> -- >>>>> *Afkham Azeez* >>>>> Director of Architecture; WSO2, Inc.; http://wso2.com >>>>> Member; Apache Software Foundation; http://www.apache.org/ >>>>> * <http://www.apache.org/>* >>>>> *email: **[email protected]* <[email protected]> >>>>> * cell: +94 77 3320919 <%2B94%2077%203320919>blog: * >>>>> *http://blog.afkham.org* <http://blog.afkham.org> >>>>> *twitter: **http://twitter.com/afkham_azeez* >>>>> <http://twitter.com/afkham_azeez> >>>>> *linked-in: **http://lk.linkedin.com/in/afkhamazeez >>>>> <http://lk.linkedin.com/in/afkhamazeez>* >>>>> >>>>> *Lean . Enterprise . Middleware* >>>>> >>>> >>>> >>>> >>>> -- >>>> Samiyuru Senarathne >>>> *Software Engineer* >>>> Mobile : +94 (0) 71 134 6087 >>>> [email protected] >>>> >>> >>> >>> >>> -- >>> *Afkham Azeez* >>> Director of Architecture; WSO2, Inc.; http://wso2.com >>> Member; Apache Software Foundation; http://www.apache.org/ >>> * <http://www.apache.org/>* >>> *email: **[email protected]* <[email protected]> >>> * cell: +94 77 3320919 <%2B94%2077%203320919>blog: * >>> *http://blog.afkham.org* <http://blog.afkham.org> >>> *twitter: **http://twitter.com/afkham_azeez* >>> <http://twitter.com/afkham_azeez> >>> *linked-in: **http://lk.linkedin.com/in/afkhamazeez >>> <http://lk.linkedin.com/in/afkhamazeez>* >>> >>> *Lean . Enterprise . Middleware* >>> >> >> >> >> -- >> Himasha Guruge >> *Software Engineer* >> WS*O2* *Inc.* >> Mobile: +94 777459299 >> [email protected] >> > > > > -- > Samiyuru Senarathne > *Software Engineer* > Mobile : +94 (0) 71 134 6087 > [email protected] > > _______________________________________________ > Dev mailing list > [email protected] > http://wso2.org/cgi-bin/mailman/listinfo/dev > > -- Thusitha Dayaratne Software Engineer WSO2 Inc. - lean . enterprise . middleware | wso2.com Mobile +94712756809 Blog alokayasoya.blogspot.com About http://about.me/thusithathilina
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
